Created
October 12, 2012 23:06
-
-
Save masonforest/3882144 to your computer and use it in GitHub Desktop.
Connascence of Position (CoP) Problem - Fixed with named parameters in Ruby 2.0
This file contains hidden or 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
=begin | |
Our "Connascence of Position" problem can be solved with named parameters available in Ruby 2.0 | |
=end | |
def do_things(puppie_count: 0, missle_count: 0) | |
puts "Played with #{puppie_count} puppies" | |
puts "Launched #{missle_count} missles" | |
end | |
puts "Everything is Fine" | |
do_things(puppie_count: 5, missle_count:0) | |
do_things(puppie_count: 10, missle_count:0) | |
do_things(puppie_count: 12, missle_count:0) | |
do_things(missle_count: 0, puppie_count: 12) | |
puts "Everything is okay! | |
=begin | |
Output: | |
Everything is Fine | |
Played with 5 puppies | |
Launched 0 missles | |
Played with 10 puppies | |
Launched 0 missles | |
Played with 12 puppies | |
Launched 0 missles | |
Played with 12 puppies | |
Launched 0 missles | |
Everything is okay! | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment