Created
February 9, 2022 21:28
-
-
Save rubyisbeautiful/197dd75d37ef1a23652535ca4b0f5a0d to your computer and use it in GitHub Desktop.
Test conditional logic with/without parens
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
#!/usr/bin/env ruby | |
def is_foo(foo='bar') | |
foo == 'foo' | |
end | |
def is_bar(foo='bar') | |
foo == 'bar' | |
end | |
should_build1 = false | |
should_build2 = false | |
git_branch = ARGV[0] | |
unless is_foo git_branch || is_bar(git_branch) | |
should_build1 = true | |
end | |
puts "old way: #{should_build1}" | |
unless is_foo(git_branch) || is_bar(git_branch) | |
should_build2 = true | |
end | |
puts "new way: #{should_build2}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment