Skip to content

Instantly share code, notes, and snippets.

@reddyonrails
Forked from dLobatog/gist:5853751
Created April 28, 2014 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reddyonrails/11361991 to your computer and use it in GitHub Desktop.
Save reddyonrails/11361991 to your computer and use it in GitHub Desktop.
Ruby 2.0 curry function example
is_weekday = lambda {|day_of_week, time| time.wday == day_of_week}.curry
sunday = is_weekday[0]
monday = is_weekday[1]
tuesday = is_weekday[2]
wednesday = is_weekday[3]
thursday = is_weekday[4]
friday = is_weekday[5]
saturday = is_weekday[6]
case Time.now
when sunday
puts "Day of rest"
when monday, tuesday, wednesday, thursday, friday
puts "Work"
when saturday
puts "chores"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment