title: CoffeeScript: Getter/Setter in Object Initializers
body: <p>ECMAScript allows us to define getters or setters as following:</p>
  
  <p><em>[text/javascript]</em></p>
  
  <pre><code>var object = {
    property: 7,
    get getable() { return this.property + 1; },
    set setable(x) { this.property = x / 2; }
  };
  </code></pre>
  
  <p>I can work around if I'm using a <em>class</em>:</p>
  
  <p><em>[text/coffeescript]</em></p>
  
  <pre><code>"use strict"
  
  Function::trigger = (prop, getter, setter) -&gt;
        Object.defineProperty @::,
                get: getter
                set: setter               
  
  class Class
        property: ''
  
        @trigger 'getable', -&gt;
                 'x'
  
        member: 0
  </code></pre>
  
  <p>But what if I want to define trigger on the <em>object directly</em> - <strong>without</strong> using <strong><code>defineProperty</code> / -<code>ies</code></strong>. I want to do something like (it's <em>not working</em> that way):</p>
  
  <p>[text/x-pseudo-coffeescript]</p>
  
  <pre><code>object =
    property: 'xhr'
    get getable: 'x'
  </code></pre>
  
  <p>It's working in JavaScript without any problems and I don't want my scripts to regress when I'm using CoffeeScript. Isn't there a way to <strong>do this as comfortable as in JavaScript</strong>/ECMAScript? Thanks.</p>