How to return settings from an object

Posted by Rockbot on Stack Overflow See other posts from Stack Overflow or by Rockbot
Published on 2012-10-09T09:36:04Z Indexed on 2012/10/09 9:36 UTC
Read the original article Hit count: 147

Filed under:

i have done something like this:

myProject =

  settings:
    duration: 500
    value: 'aValue'

  aFunction: ->
    myElement.fadeOut myProject.settings.duration

This is just a sample but my project is like that. A lot of times i have to reference to the settings to get a certain value, and i always have to write myProject.settings.value, and it doesn´t look good.

My question is, can I call a function that returns the wanted value? Something like this?

aFunction ->
  myElement.fadeOut getSetting(duration)

I tried with

getSetting: (param) ->
  myProject.settings.param

but failed? Why is that? Thank you!

© Stack Overflow or respective owner

Related posts about coffeescript