Local accumulators for cleaner comprehensions

No idea if this was already proposed, but the problem with explicit else could be solved with a dedicated ‘conditional assignment’ syntax, for example

x = 4 if a > 10

that would resolve to

x =
  if a > 10 do
    4
  else
    x
  end

It’s still an expression and doesn’t look imperative. Then we’d “only” have the for problem left :smile:

P.S. and it’s quite Pythonic :smiley:

9 Likes