i would play a bit with Ruby.
Now i have a little problem, which i cannot solve.
The code:
@href = "http://localhost:3000"
def link(title, href)
if href.nil?
href = @href
else
href = href
end
output = "<a href=\"#{href}\">"
output << "#{title}"
output << "</a>"
puts output
end
alias link_to link
link_to("Google","")
Whats the problem in my code?
I want set a default value for the href,if it is nil.
Greets,
Peter
The problem is here
You should use
.nil? or .empty?as the condition.