cheat sheets.

$ cheat pola_violations
POLA/PLA
--------
POLA or PLA, the priniciple of least astonishment is documented at
http://en.wikipedia.org/wiki/Principle_of_least_astonishment

Ruby definitely scores on this front. It surprises the programmer the least. But
still, there are some quirks. This cheat sheet is an attempt to list Ruby's
violations of POLA. Of course, the list  may be personal.

1. String#to_i -- as of Ruby 1.9.2 returns 0 when the receiver does not start
with numerics!  (Naturally, it returns 0 also when receiver is "0").

   I'd have preferred nil to be returned in this case. Of course, there are
   cases where a return value of 0 is useful (cases where non-numeric string
   should contribute nothing to an aggregate function), but still, this is a
   candidate for POLA violation.

   See http://www.ruby-forum.com/topic/78767 for some interesting discussions
   and workarounds.
Version 6, updated 429 days ago.
. o 0 ( | previous | history | revert to | current | diff )
( add new | see all )