Skip to content

Instantly share code, notes, and snippets.

@joofsh
Created September 13, 2012 20:08
Show Gist options
  • Save joofsh/3717218 to your computer and use it in GitHub Desktop.
Save joofsh/3717218 to your computer and use it in GitHub Desktop.
class TaxCalculator
def initialize(name, &block)
@name, @bock = name, block
end
def get_tax(amount)
puts "#@name on #{amount} = #{@block.call(amount)}"
end
end
tc = TaxCalculator.new("sales tax") { |amt| amt * 0.075}
tc.get_tax(100)
tc.get_tax(250)
#The error I get:
#`get_tax': undefined method `call' for nil:NilClass (NoMethodError)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment