Class inheritance uses < , not << , and the first has nothing to do with the << method.
Ruby has a high tolerance for indentation in space; almost anywhere, any number of spaces could be placed, including newlines, between a function call and an argument.
E. g :.
'aaa'. length #⇒ 3
and
'aaa' .length #⇒ 3
both are absolutely correct.
<< is a generic method that can be overwritten in any class. Here's supposedly String#<< method that adds an argument to a string receiver.
In general, you can rewrite this method in any arbitrary class:
class A attr_accessor :var def initialize @var = 5 end def << value @var += value end end a = A.new a.var #⇒ 5 a << 37 a.var #⇒ 42
source share