Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

collections.getDefault() (and .get() with a default arg) seems completely broken on Map #176

Open
cdmcmahon opened this issue Mar 28, 2017 · 0 comments
Labels
Milestone

Comments

@cdmcmahon
Copy link

cdmcmahon commented Mar 28, 2017

Copy and paste the following into RunKit and I would expect the second and third console.log statements to print 'def', but they print undefined. Perhaps I'm missing something? The documentation seems pretty clear so I'm somewhat at a loss.

const Map = require('collections/map');

const foo = new Map();

foo.set('a', 'aa');
foo.set('b', 'bb');
foo.set('c', 'cc');

// EXISTING VALUE

let a = foo.get('a');
console.log(a);
// >>> 'aa'

// DEFAULT ARGUMENT

let def = foo.get('d', 'def');
console.log(def);
// >>> undefined

// DEFAULT FUNCTION SET

foo.getDefault = function() { 
    return 'def';
};

let def2 = foo.get('d');
console.log(def2);
// >>> undefined
@hthetiot hthetiot added the bug label May 5, 2017
@hthetiot hthetiot added this to the 5.0.x milestone May 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants