-
-
Save joho/26065 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DRY temporary variables that require single use only, without assignment... seems | |
# useful for configuration files perhaps? urgh. | |
class Object | |
def with(object) | |
yield(object) | |
end | |
end | |
@reports = [] | |
with 'Sales' do |group| | |
@reports << Report.new(:name => 'First', :group => group) | |
@reports << Report.new(:name => 'Second', :group => group) | |
@reports << Report.new(:name => 'Third', :group => group) | |
end | |
# this is less typing. | |
begin | |
group = 'Traffic' | |
@reports << Report.new(:name => 'Fourth', :group => group) | |
@reports << Report.new(:name => 'Fifth', :group => group) | |
@reports << Report.new(:name => 'Sixth', :group => group) | |
end | |
puts group # => 'Traffic' # => FAIL | |
# oops, is a ruby 1.9 thing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment