« |
Main
| »
November 12, 2009
In the spirit of the
perl don't module, here's the
ruby maybe gem that provides three
new constructs -- maybe, probably,
and unlikely -- as shown here:
require 'rubygems'
require 'maybe'
puts 'Maybe'
5.times do |x|
maybe { puts x }
end
puts 'Probably'
5.times do |x|
probably { puts x }
end
puts 'Unlikely'
5.times do |x|
unlikely { puts x }
end
producing this
Maybe
1
2
Probably
0
1
3
4
Unlikely
4
To install,
download maybe-0.0.1.gem and run
% sudo gem install maybe-0.0.1.gem
Posted by jeff at November 12, 2009 10:56 PM