use of << vs < in Ruby


June 19, 2014

Sometimes I confuse the difference between << and < in ruby and when to use them.

<< is used to push an item into an array such as


existing_array << new_item_into_array

while < is used to create a subclass of a class


class NewSubclass < OriginalClass
end

you can see this in rails when you create a new controller or model



Previous Posts