What does #{…} mean?

前端 未结 3 1997
南方客
南方客 2020-12-12 02:12

Such as in the following code from Why\'s Poignant Guide:

def wipe_mutterings_from( sentence ) 
     unless sentence.respond_to? :include?
         raise Arg         


        
3条回答
  •  伪装坚强ぢ
    2020-12-12 02:47

    #{} is used for Ruby interpolation. In this example,

    this will raise an ArgumentError with the message,

    cannot wipe mutterings from a

    This is a useful read - String concatenation vs. interpolation in Ruby

提交回复
热议问题