Ruby

30
1274 reads

March 1, 2013

Array Copy


Note that when you use the assignment operator, =, to assign one array variable to another variable, you are actually assigning a reference to the array itself – you are not making a copy.

26
1305 reads

March 1, 2013

Array Compare


A few words need to be said about the comparison operator <=>.

28
1490 reads

March 1, 2013

Array Assign


You can also make assignments by indexing into an array. Here, for example, first create an empty array then put items into indexes 0, 1 and 3.

26
1538 reads

March 1, 2013

Append and Concatenation


Be careful to note the difference between concatenating using + to add the values from the second array to the first and appending using << to add the second array as the final element of the first

378
4040 reads

February 28, 2013

Writing Program at Run Time


A very simple program-writing program
Enter code at prompt. Enter blank line to eval
Enter l to list program and q to quit

311
2803 reads

February 28, 2013

Special Eval:- Str_eval


Most of the time you will probably embed rather simple bits of code between the #{ and } delimiters in double-quoted strings. Often you might embed variable names, say, or mathematical expressions:

217
2373 reads

February 28, 2013

Send


You may use the send method to call a method with the same name as the specified symbol

26
1218 reads

February 28, 2013

Remove Methods2


If a method with the same name is defined for an ancestor of that class, the ancestor class method is not removed.

376
2786 reads

February 28, 2013

Remove Methods


In addition to creating new methods, there may be times when you want to remove existing methods. You can do this using remove_method within the scope of a given class.

164
2013 reads

February 28, 2013

Handling Missing Method2


The method_missing method can also take a list of incoming arguments (*args) after the missing method name