5 ms·
this is something between a joke and a thought experiment. function cason(x){ switch(x[0]){ case "movie": switch(x[1]) { case "name"
by hokus 7y ago
this is something between a joke and a thought experiment.
function cason(x){
switch(x[0]){
case "movie": switch(x[1]) {
case "name" : return "Interstellar";
case "year" : return 2014;
case "is_released": return true;
case "director" : return "Christopher Nolan";
case "cast": switch(x[2]){
case 0: return "Matthew McConaughey";
case 1: return "Anne Hathaway";
case 2: return "Jessica Chastain";
case 3: return "Bill Irwin";
case 4: return "Ellen Burstyn";
case 5: return "Michael Caine";
}
}
}
}
- geofft 7y agoWell, that's kind of the inverse of writing switch statements like def license(kernel): return {"Linux": "GPL", "FreeBSD": "BSD", "NT": "Proprietary"}[kernel]