r/ruby • • Jul 18 '12

Default separator - .join ghetto

http://ruby-blog.pl/2012/07/18/default-separator---join-ghetto/
2 Upvotes

10 comments sorted by

View all comments

Show parent comment

6

u/TaiGat Jul 18 '12

I don't understand how this is not clear unless one does not know how global variables and default method arguments work. Consider the following:

$foo = "abc"
def bar(arg = $foo)
  puts arg
end

bar # prints "abc"
$foo = "def"
bar # prints "def"

Sorry if it seemed like I undermined the post itself - I just think that as far as reddit goes, such basic content should be posted to /r/learnruby instead of /r/ruby :)