Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arr = [1,2,"three", 4]
- squares = []
- arr.each do |el|
- #We are going through a loop to square each element in the array (arr)
- begin
- #Here is the part where we try to do some logic
- squares.push(el * el)
- rescue
- #Here we have a rescue, which will do something, whatever you put in here, and will tell the array loop to go to the next step
- p "I was rescued"
- end
- end
- p squares
Add Comment
Please, Sign In to add comment