From: "Brian Schröder" Date: 2005-06-01T02:47:22+09:00 Subject: Re: Operation on Classes On 31/05/05, aartist wrote: > While learning ruby, I want to study from the perspective of classes. > > Exmaple: > Given: # Array, Index, Object > Operations: array[index] = obj -> obj > > Given: # Two Arrays > array & other_array -> an_array > array + other_array -> an_array > array - other_array -> an_array > array <=> other_array -> -1, 0, +1 > array == other_array -> bool > > Given: # Array, Object > array.push(obj) -> array > array << obj -> array > > etc.. > > So the idea is to know, what is possible with given objects of > different kind. > > Is there any way to generate it? > > Maybe I do not understand you correctly, but every object has the .class function. $ irb irb(main):001:0> (Array.new + Array.new).class => Array irb(main):002:0> ([] & []).class => Array irb(main):003:0> ([1,2,3] <=> []) => 1 irb(main):004:0> ([1,2,3] <=> []).class => Fixnum irb(main):005:0> ([1,2,3] == []).class => FalseClass regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/