Created
September 13, 2012 20:08
-
-
Save joofsh/3717218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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