I was reading through confident ruby and I was trying out how to define a reusable proc. From the examples given, I wrote this:
I have come across the following code in erb library. Note the double (( )):The following locatia= method is another version without the (( )) for testing:
How can I pass an argument to the definition of a singleton method of  on A, in other words A['some_argument']?
I have a string "990822". I want to know if the string starts with "99".I could achieve this by getting the first two characters of the string, then check if this is equal to "99". How do I get the first two characters from a string?
I have an array of hashes like this:I need to check if email: 'firstname.lastname@example.org' and valid: true both exist in a single hash.
How can I merge two arrays with the unique key:to get the following?Use Enumerable#group_by:
I have a string like "a_b_c" or "a_b_c_d" or "a_b_c_d_e". I want to split the string at the last underscore.
Method find_something may return nil. In the following code,find_something(id) is called twice. This is a smell that I want to avoid. Is there a way to avoid redundancy in this expression?
I just stumbled upon a concept I don't understand. What is the explanation behind this? What theory am I missing?
Is there a way to avoid the redondance on this expression :find_something(id) is called twice. This is a smell that I want to avoid.