Skip to content

Instantly share code, notes, and snippets.

@seratch
Created August 10, 2012 11:14
Show Gist options
  • Save seratch/3313484 to your computer and use it in GitHub Desktop.
Save seratch/3313484 to your computer and use it in GitHub Desktop.
Scaruby compose/and_then example
require 'scaruby/core_ext'
hello = lambda { 'Hello!' }
twice = lambda { |x| x * 2 }
twice.compose(hello).apply() # or call()
hello.and_then(twice).apply()
cap = lambda { |x| x.capitalize }
twice.compose(cap).apply('ruby!')
cap.and_then(twice).apply('ruby!')
source "http://rubygems.org/"
gem 'scaruby'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment