-
-
Save aitor/461218 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
def wadus(wadus = nil, options = {}) | |
puts "wadus = #{wadus.inspect}" | |
puts "options = #{options.inspect}" | |
end | |
wadus | |
# wadus = nil | |
# options = {} | |
# OK | |
wadus "wadus" | |
# wadus = "wadus" | |
# options = {} | |
# OK | |
wadus "wadus", :wadus => "wadus" | |
# wadus = "wadus" | |
# options = {:wadus=>"wadus"} | |
# OK | |
wadus :wadus => "wadus" | |
# wadus = {:wadus=>"wadus"} | |
# options = {} | |
# Instead of what I wanted which is: | |
# wadus = nil | |
# options = {:wadus=>"wadus"} | |
# In Rails I've seen things like: | |
def jander(wadus = nil, options = {}) | |
if wadus.is_a?(Hash) | |
options = wadus | |
wadus = nil | |
end | |
puts "wadus = #{wadus.inspect}" | |
puts "options = #{options.inspect}" | |
end | |
jander | |
# wadus = nil | |
# options = {} | |
# OK | |
jander "wadus" | |
# wadus = "wadus" | |
# options = {} | |
# OK | |
jander "wadus", :wadus => "wadus" | |
# wadus = "wadus" | |
# options = {:wadus=>"wadus"} | |
# OK | |
jander :wadus => "wadus" | |
# wadus = nil | |
# options = {:wadus=>"wadus"} | |
# OK | |
# But that's ugly man!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment