Re:How to Write a Spelling Corrector
by misiti3780 on Thursday September 08, 2016 @12:59PM
(#12454783)
that is a great idiom. i remember the first time i saw it (possibly in is very essay), i thought it was awesome. I use it all over the place now. it is similiar to the javascript ternary operator [1], which I also find to be very useful
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
[ Parent
| on HN ]
Re:How to Write a Spelling Corrector
by nommm-nommm on Thursday September 08, 2016 @03:41PM
(#12456574)
Pretty much every language has a ternary conditional operator: C++, Java, Python, C#, Ruby....
Re:How to Write a Spelling Corrector
by kevin_thibedeau on Thursday September 08, 2016 @07:17PM
(#12458316)
This isn't the Python ternary which is:
varX = 'X' if boolean else 'Y'
# And is chainable in a more natural way than C*:
varX = 'X' if boolean else 'Y' if other else 'Z'