Guest User

Untitled

a guest
Jun 21st, 2014
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. def calculate(*array)
  2. calculation = array.last
  3. if calculation.is_a?(Hash)
  4. numbers = array.select{ |i| i.is_a? Integer}
  5. else
  6. calculation = "add"
  7. numbers = array
  8. end
  9. if calculation = "add"
  10. add (numbers)
  11. else
  12. subtract(numbers)
  13. end
  14. end
  15.  
  16. calculate(4, 5, add: true)
  17.  
  18. Error message :
  19.  
  20. TypeErrorArray can't be coerced into Fixnum
Advertisement
Add Comment
Please, Sign In to add comment