What is <<- in ruby?

前端 未结 2 589
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 06:03

From the Ruby_Newbie Guide to Symbols:

Author is trying to show a simplified implementation of the attr_writer method.

#!/usr/bin/env ruby

def make_me_a         


        
2条回答
  •  借酒劲吻你
    2021-01-21 06:18

    It's a heredoc. From the "Here Documents" documentation:

    If you are writing a large block of text you may use a “here document” or “heredoc”:

    expected_result = <

    The heredoc starts on the line following < and ends with the next line that starts with HEREDOC. The result includes the ending newline.

提交回复
热议问题