Skip to content

Commit

Permalink
Add Kernel#fail
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Sep 18, 2013
1 parent 20d55fb commit 9a7cba4
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions corelib/kernel.rb
Expand Up @@ -483,4 +483,24 @@ def freeze
def frozen?
@___frozen___ || false
end

def fail(*args)
case args.length
when 0
raise $! ? $! : RuntimeError

when 1
if String === args.first
raise RuntimeError, args.shift
else
raise args.shift
end

when 2
raise args.shift, args.shift

when 3
raise args.shift, args.shift, args.shift
end
end
end

0 comments on commit 9a7cba4

Please sign in to comment.