Can I access a variable within a heredoc in Ruby?

前端 未结 1 1820
终归单人心
终归单人心 2021-02-11 16:15

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:44

    You can interpolate just like in normal strings

    <<-TERMINATOR
      Example #{p[:name]} blah blah blah
    TERMINATOR
    
    0 讨论(0)
提交回复
热议问题