Created
February 12, 2013 18:35
-
-
Save nixpulvis/4772101 to your computer and use it in GitHub Desktop.
The worst 3 line I've ever written, that also works.
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
s = options[:sudo].nil? ? sudo? || dependency.sudo? : options[:sudo] | |
f = options[:flags].nil? ? "#{flags+' ' if flags}#{dependency.flags}" : options[:flags] | |
system "#{'sudo ' if s}#{program} #{command} #{f+' ' unless f.to_s == ''}#{dependency}" |
That is not equivalent. Imagine this case:
options[:sudo] = false
sudo? = true
dependency.sudo? = true
You would say s == true
but it shouldn't. I want options[:sudo]
to have a higher precedence then anything else.
Keep in mind false.nil? == false
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: