Content deleted Content added
Subtitle added |
Some more examples added (taken from the German version) |
||
Line 33:
== Examples ==
Here is
>> -199.abs # Die number 199 is an object; the method ''abs'' is called.
=> 199
>> "Ruby is cool".length # ''length'' is a method of String objects
=> 13
>> "Rick".index("c")
=> 2
>> "John".swapcase
=> "jOHN"
>> #Arrays
?> [11, 5, 7, 2, 13, 3].sort
=> [2, 3, 5, 7, 11, 13]
>> [11, 5, 7, 2, 13, 3].sort.reverse
=> [13, 11, 7, 5, 3, 2]
# Execute the following block of code 10 times
|