by ghanrt · 5y ago · 0 comments
let ch = if index < strlen then str.charAt(index) else 0
Eminently readable and less boring than long if/else chains in Python.On a side note, having gotten used to newer languages, an option type sure is a nice thing.
>>> foo = 10
>>> bar = foo if foo > 5 else 0
>>> bar
10
>>> bar = foo if foo < 5 else 0
>>> bar
0"for ch in index:"
reads pretty cleanly to me.