I tried my ruby out on this site : http://www.compileonline.com/execute_ruby_online.php
So I have this script :
roelof = "www.codewars.com#about"
def remove_url_anchor(roelof)
answer = roelof.gsub(/\#\w+/,"")
puts answer
end
And it gives this wierd error message . roelof is used on several places.
So why this error message?
Roelof
roelof = "www.codewars.com#about"
def remove_url_anchor(roelof) # this is declaring a new variable
as a parameter for the method
answer = roelof.gsub(/\#\w+/,"") # this uses the parameter, not the
variable you set to "www....."
puts answer
end
# you need a line like the following to actually use the variable
remove_url_anchor(roelof)
···
From: Roelof Wobben <r.wobben@home.nl>
To: Ruby users <ruby-talk@ruby-lang.org>
Date: 06/06/2014 07:48 AM
Subject: main.rb:3: warning: assigned but unused variable - roelof
Sent by: "ruby-talk" <ruby-talk-bounces@ruby-lang.org>
I tried my ruby out on this site :
http://www.compileonline.com/execute_ruby_online.php
So I have this script :
roelof = "www.codewars.com#about"
def remove_url_anchor(roelof)
answer = roelof.gsub(/\#\w+/,"")
puts answer
end
And it gives this wierd error message . roelof is used on several places.
So why this error message?
Roelof
Thanks,
Things can be so simple that you overlooked it.
Roelof
···
To: ruby-talk@ruby-lang.org
Subject: Re: main.rb:3: warning: assigned but unused variable - roelof
From: HANSEM1@nationwide.com
Date: Fri, 6 Jun 2014 08:01:14 -0400
roelof = "www.codewars.com#about"
def remove_url_anchor(roelof) # this is declaring
a new variable as a parameter for the method
answer = roelof.gsub(/\#\w+/,"") # this uses
the parameter, not the variable you set to "www....."
puts answer
end
# you need a line like the following
to actually use the variable
remove_url_anchor(roelof)
From:
Roelof Wobben <r.wobben@home.nl>
To:
Ruby users <ruby-talk@ruby-lang.org>
Date:
06/06/2014 07:48 AM
Subject:
main.rb:3: warning:
assigned but unused variable - roelof
Sent by:
"ruby-talk"
<ruby-talk-bounces@ruby-lang.org>
I tried my ruby out on this site :
http://www.compileonline.com/execute_ruby_online.php
So I have this script :
roelof = "www.codewars.com#about"
def remove_url_anchor(roelof)
answer = roelof.gsub(/\#\w+/,"")
puts answer
end
And it gives this wierd error message . roelof is used on several places.
So why this error message?
Roelof