ruby on rails - cattr_accessor default value syntax -


i'm bit miffed why this:

cattr_accessor :aggregate { true } 

fails error:

syntax error, unexpected '{', expecting keyword_end   cattr_accessor :aggregate { true }                             ^ 

while same thing, do/end seems doing right thing:

cattr_accessor :aggregate true end 

(but whhhay verbose ;)

the source :http://api.rubyonrails.org/classes/class.html#method-i-cattr_writer bit crufty given time have spend on this. thoughts?

isn't following language binding precedence?

  • brace form has higher precedence , bind last parameter if invocation made w/o parens.
  • do/end form has lower precedence , bind invocation without parens.

if don't want write end form, need put parenthesis around call.

cattr_accessor(:is_admin) { true } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -