Ruby lets you redefine backticks

Posted . Visible to the public.

This actually works:

class Klass

  def initialize
    `hi world`
  end

  def `(message)
    puts "Called with backticks: #{message}"
  end
  
end

Klass.new # Prints "Called with backticks: hi world"

Hat tip to @jcoglan Show archive.org snapshot .

Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2014-07-11 15:39)