The most voted Ruby question on Stack Overflow
stackoverflow.com
stackoverflow.com
RubySpec, for those who aren't familiar with it, is an attempt to write an executable specification for the language. Ruby's definitely suffered from not having this in the past. https://github.com/rubyspec/rubyspec/ and specifically case statement spec at https://github.com/rubyspec/rubyspec/blob/master/language/ca...
Most functional languages have, I think, somewhat better systems in that there's less magic[0], you can unwrap/extract values and you can add further conditions on values (guards)[1][2][3].
Some modern multiparadigm languages have lifted this style e.g. Scala or Rust.
[0] because case/when relies on the non-commutative `===` its behavior can be surprising
[1] http://learnyouahaskell.com/syntax-in-functions#case-express...
[2] http://learnyousomeerlang.com/syntax-in-functions#in-case-of
[3] http://en.wikibooks.org/wiki/F_Sharp_Programming/Pattern_Mat...
Also, it's not a simple control structure, Ruby's case/when does not do equality checks (via ==) it does match checks (via ===) so you can match integers to ranges:
> (1..3) === 2
=> true
or instances to classes > String === "foo"
=> true
But `===` is not commutative: > 2 === (1..3)
=> false
and the matches can seem somewhat arbitrary: > (1..5) === (2..3)
=> false
[0] http://www.techotopia.com/index.php/The_Ruby_case_Statementmade my day, thanks.
But "I don't believe in ..." or "She doesn't believe in ..." is a running gag in my circle of friends.
"He got rather bad teeth so he had to pay much money for getting them done..." - "Didn't his insurance cover this?" - "He doesn't believe in insurance!"
And I think Ruby management has its negligence; it's weird that a so popular and mature language has so much lack of informations about its behaviour.
Java: http://stackoverflow.com/questions/11227809/why-is-processin...
Php: http://stackoverflow.com/questions/60174/how-can-i-prevent-s...
Javascript: http://stackoverflow.com/questions/111102/how-do-javascript-...
Ruby, Python, Javascript: unique-ish language features
Java: general comp-sci corner cases
C, C++: what does this obscure operator mean
Erlang, Haskell, Node: how to get started
Go: how to live without features that were intentionally not included
PHP: How to avoid the security pitfalls that the standard library encourages
Seems about right... (Though I'm surprised to see Node alongside Erlang and Haskell in terms of people not knowing where to start)