# Problem with CanJS set function

**URL:** <https://forums.bitovi.com/t/problem-with-canjs-set-function/401>\
**Category:** CanJS\
**Created:** [September 5, 2016, 3:23am UTC](https://forums.bitovi.com/t/problem-with-canjs-set-function/401 "2016-09-05T03:23:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ALIMOEdm](https://avatars.discourse-cdn.com/v4/letter/a/dbc845/32.png) [@ALIMOEdm](https://forums.bitovi.com/u/ALIMOEdm)\
**Post date:** [September 5, 2016, 3:23am UTC](https://forums.bitovi.com/t/problem-with-canjs-set-function/401/1 "2016-09-05T03:23:01Z")

</div>

Hi guys, I new in CanJS but when i read article about Map set function i couldn’t realize the example about merge new value into current value. But when i try run the sample, error is appeared: **TypeError: [this.info](http://this.info) is undefined**

Sample from [https://canjs.com/docs/can.Map.prototype.define.set.html](https://canjs.com/docs/can.Map.prototype.define.set.html)  
(in the end of the page)

```
Contact = can.Map.extend({
  define: {
    info: {
      set: function(newVal){
        this.info.attr(newVal);
        return this.info;
      }
    }
  }
})
var alice = new Contact({
        info: {name: 'Alice Liddell', email: 'alice@liddell.com'}
    });
alice.attr(); // {name: 'Alice Liddell', 'email': 'alice@liddell.com'}
alice.info._cid; // '.map1'
alice.attr('info', {name: 'Allison Wonderland', phone: '888-888-8888'});
alice.attr();
//{
// name: 'Allison Wonderland',
// email: 'alice@liddell.com',
// phone: '888-888-8888'
//}
alice.info._cid; // '.map1'
```

---

<div class="post-metadata">

**Author:** ![pYr0x](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/pyr0x/32/95_2.png) [@pYr0x](https://forums.bitovi.com/u/pYr0x)\
**Post date:** [September 5, 2016, 7:15pm UTC](https://forums.bitovi.com/t/problem-with-canjs-set-function/401/2 "2016-09-05T19:15:22Z")

</div>

the docs is maybe wrong.  
the sample should look like this:

```auto
Contact = can.Map.extend({
  define: {
    info: {
      set: function(newVal){
        if(this.info) {
          return this.info.attr(newVal.serialize());
        }else{
          return newVal
        }
      }
    }
  }
})

```

see [http://jsbin.com/socihinada/edit?html,js,console](http://jsbin.com/socihinada/edit?html,js,console)
