Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
begin
|
||||
# some code that may raise an exception
|
||||
rescue ExceptionClassA => a
|
||||
# handle code
|
||||
rescue ExceptionClassB, ExceptionClassC => b_or_c
|
||||
# handle ...
|
||||
rescue
|
||||
# handle all other exceptions
|
||||
else
|
||||
# when no exception occurred, execute this code
|
||||
ensure
|
||||
# execute this code always
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
values = ["1", "2.3", /pattern/]
|
||||
result = values.map {|v| Integer(v) rescue Float(v) rescue String(v)}
|
||||
# => [1, 2.3, "(?-mix:pattern)"]
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
def some_method
|
||||
# ...
|
||||
if some_condition
|
||||
throw :get_me_out_of_here
|
||||
end
|
||||
# ...
|
||||
end
|
||||
|
||||
catch :get_me_out_of_here do
|
||||
for ...
|
||||
for ...
|
||||
some_method
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
puts "continuing after catching the throw"
|
||||
Loading…
Add table
Add a link
Reference in a new issue