Add singleton method to a string instance : singleton method « Class « Ruby






Add singleton method to a string instance


  sam = ""

  def sam.play(a)
    "this is a test"
  end

  sam.play("song")

 








Related examples in the same category

1.Add a singleton method to a instance object
2.Singleton method not copied
3.Use extend to include a module to create single methods