Can I access a variable within a heredoc in Ruby?

前端 未结 1 527
借酒劲吻你
借酒劲吻你 2021-02-11 15:50

If I have a method

  def some_method p = {}
    string = <<-MY_TERMINATOR
      Example text blah blah
      lorem ipsum something or another
    MY_TERMIN         


        
1条回答
  •  爱一瞬间的悲伤
    2021-02-11 16:49

    You can interpolate just like in normal strings

    <<-TERMINATOR
      Example #{p[:name]} blah blah blah
    TERMINATOR
    

    0 讨论(0)
提交回复
热议问题