我在 MiddleMan 做一个项目。试图将一个方法的结果作为另一个方法的参数传递。我遇到了逗号和括号的各种语法问题。一切对我来说都是正确的,我疯了吗?提前致谢!
我遇到问题的方法调用是create_campus_subnav()
module SubnavHelper
def create_subnav_link ( label, link="" )
if link == ""
link = label
end
return " <li id='item-#{link}'><a class='title' id='link-#{link}'>#{label}</a></li>"
end
def create_subnav (*links)
subnav = "\
<nav class='nav-sub'>\
<div class='nav-wrap'>\
<ul class='nav-list'>"
links.each do |attr,val|
subnav += " attr: " + attr;
subnav += " val: " + val;
# subnav += args["attr"] + "\n"
end
subnav += "\
</ul>\
</div>\
</nav>"
return subnav
end
def create_campus_subnav
subnav = create_subnav (
create_subnav_link ("Campus Overview", "Overview"),
create_subnav_link ("About", "About"),
create_subnav_link ("Admissions"),
create_subnav_link ("Career Services" "CareerServices"),
create_subnav_link ("Schedules, Tuition & Fees" "Tuition"),
create_subnav_link ("Financial Assistance & Scholarships" "FinancialAssistance"),
create_subnav_link ("Faculty")
)
puts subnav
end
end
和错误:
/dev/config.rb:54:in `require': /gia/dev/helpers/subnav_helper.rb:36: syntax error, unexpected ',', expecting ')' (SyntaxError)
create_subnav_link ("Campus Overview", "Overview"),
^
/dev/helpers/subnav_helper.rb:36: syntax error, unexpected ')', expecting keyword_end
create_subnav_link ("Campus Overview", "Overview"),
^
/dev/helpers/subnav_helper.rb:37: syntax error, unexpected ',', expecting ')'
create_subnav_link ("About", "About"),
^
/dev/helpers/subnav_helper.rb:37: syntax error, unexpected ')', expecting keyword_end
create_subnav_link ("About", "About"),
^
/dev/helpers/subnav_helper.rb:39: syntax error, unexpected tLPAREN_ARG, expecting keyword_do or '{' or '('
create_subnav_link ("Career Services" "...
^
/dev/helpers/subnav_helper.rb:39: syntax error, unexpected ',', expecting keyword_end
...er Services" "CareerServices"),
... ^
/dev/helpers/subnav_helper.rb:41: syntax error, unexpected tLPAREN_ARG, expecting keyword_do or '{' or '('
create_subnav_link ("Financial Assistance & Schol...
^
/dev/helpers/subnav_helper.rb:41: syntax error, unexpected ',', expecting keyword_end
...rships" "FinancialAssistance"),
... ^
/dev/helpers/subnav_helper.rb:43: syntax error, unexpected ')', expecting keyword_end