Guest User

Untitled

a guest
Oct 18th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. arr = [1,2,"three", 4]
  2. squares = []
  3.  
  4.  
  5. arr.each do |el|
  6. #We are going through a loop to square each element in the array (arr)
  7. begin
  8. #Here is the part where we try to do some logic
  9. squares.push(el * el)
  10. rescue
  11. #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
  12. p "I was rescued"
  13. end
  14. end
  15.  
  16.  
  17. p squares
Add Comment
Please, Sign In to add comment