Created
March 5, 2016 11:54
-
-
Save gerhardberger/faa6d37dcc8285499055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ node --harmony_destructuring match.js -5 | |
'use strict' | |
let x = Number(process.argv[2]) | |
let { true: a } = { | |
[ x > 0 ]: 1, | |
[ x < 0 ]: -1, | |
[ x === 0 ]: 'wow' | |
} | |
console.log(a) | |
let match = o => { | |
let { true: a } = o | |
return a | |
} | |
let b = match({ | |
[ x > 0 ]: 1, | |
[ x < 0 ]: -1, | |
[ x === 0 ]: 'wow' | |
}) | |
console.log(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment