Monday, February 12, 2007

Many Happy Returns

Ruby has implicit returns -- every method responds with something, whether you need it to or not.

For those unaccustomed to this, it may feel wrong. "If the result is meaningful, have the code tell me it is!" ...I disagree. If you're thinking this way, you're thinking procedurally.

Instead, think functionally. Always make your methods return something useful. If you can think of nothing more meaningful to return, return self. Method chaining is your friend.

No comments: