Ruby:
- I just realized that variables defined in if statements aren't out of scope from the rest of the code block. I don't know why I thought they were.
- Learned about begin, rescue, and ensure for error handling
- I'm still not sure why you do "Exception => e" after rescue in order to get the exception object, I will look into this tomorrow
- Learned about undef to remove a function
- Learned about differences between Integer("123abc") and "123abc".to_i.
- The first throws an exception, and the second returns 123
- Learned that calling 'method()' is equivalent to calling 'method' unless method=somevalue is state.
- For example:
def method() "Abcdefg" end puts method # outputs Abcdefg puts method() # outputs Abcdefg method = "Other string" puts method # outputs Other string puts method() # outputs Abcdefg
Hmmm... I'm liking Python more and more ;-)
ReplyDelete