<< - value in Ruby

What does <<-the following method / context mean ?

class_eval <<-RUBY, __FILE__, __LINE__ + 1
def destroy_associations
  association(:#{middle_reflection.name}).delete_all(:delete_all)
  association(:#{name}).reset
  super
end
RUBY
+4
source share
3 answers

It describes the beginning of the document here. You are probably confusing that the document here begins on the next line; everything that follows this expression inside this line is a continuation of this document. Thus, given that the content of the document is presented as heredoc, the expression is equivalent to:

class_eval heredoc, __FILE__, __LINE__ + 1

, , , (__FILE__) (.. , __LINE__ + 1) 1.

+5

, "heredoc".

:

<<[ID]
contents
[ID]

<<-[ID]
contents
[ID]

, [ID] , [ID] , .

+8

All Articles