Skip to content

Instantly share code, notes, and snippets.

@seebq
Created May 29, 2009 20:51
Show Gist options
  • Save seebq/120206 to your computer and use it in GitHub Desktop.
Save seebq/120206 to your computer and use it in GitHub Desktop.
$ irb
>> omar = ["a", "b", "c"]
=> ["a", "b", "c"]
>> omar.to_s
=> "abc"
>> class Array
>> def to_s
>> output = "I am an Array. I contain: "
>> self.each {|x| output += " element: #{x} " }
>> return output
>> end
>> end
=> nil
>> omar.to_s
=> "I am an Array. I contain: element: a element: b element: c "
>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment