Thanks,
Things can be so simple that you overlooked it.
Roelof
To: [email protected]
Subject: Re: main.rb:3: warning: assigned but unused variable - roelof
From: [email protected]
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 W. [email protected]
To:
Ruby users [email protected]
Date:
06/06/2014 07:48 AM
Subject:
main.rb:3: warning:
assigned but unused variable - roelof
Sent by:
“ruby-talk”
[email protected]
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