Skip to content

Instantly share code, notes, and snippets.

@loren-osborn
Created September 17, 2015 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loren-osborn/6c4d9593ec75abf53699 to your computer and use it in GitHub Desktop.
Save loren-osborn/6c4d9593ec75abf53699 to your computer and use it in GitHub Desktop.
Code:
def foo(bar, *baz, &block)
puts "trying to call foo #{@bar} (#{@bar.class.to_s.to_sym}) *baz = #{@baz} (#{@baz.class}) &block = #{@block} (#{@block.class})\n"
if (bar == nil) || (bar.class == NilClass) || [*bar].empty?
puts "firing exception\n"
raise "There should be data here"
end
end
program output:
trying to call foo (NilClass) *bar = (NilClass) &block = (NilClass)
question:
How the function being called that the output is as shown without printing "firing exception"?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment