Ruby에서 약간 재생합니다.Ruby의 변수
이제 약간 문제가 있습니다. 해결할 수 없습니다.
코드 :
@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","")
뭐죠 내 코드에 문제가? nil 인 경우 href의 기본값을 설정하려고합니다.
접견,
피터
,이 두 가지 작동합니다 :'LINK_TO를 (" Google ", nil); link_to ("Google "," ") – farnoy
차갑다. 그게 전부 야. – pkberlin