Re: Functional Programming is Dead, Long Live Expression-Ori...
by sherwin on Friday July 20, 2012 @03:10AM
(#4269781)
I think Ruby does a pretty good job with this, as far as an object oriented main stream language goes. For example, the switch case example from the article can be implemented in ruby as
case n:
when 1: "one"
when 2: "two"
etc, and the entire construct can be assigned to a variable because it is an expression.
etc, and the entire construct can be assigned to a variable because it is an expression.
As an aside, ruby 1.9 also supports generic predicates for case statements through lambdas, which is very concise and powerful. Example: https://gist.github.com/838163, source: http://flazz.me/predicates-in-ruby-case-statements