-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
consider a function like this:
def if_one_two_none_zero(o: Option[Int]):
match o:
case Some(i) if i matches 1: Some(2)
case Some(i): Some(i)
case None: Some(0)
we could have written this as:
def if_one_two_none_zero(o: Option[Int]):
match o:
case Some(i) if i matches 1: Some(2)
case Some(_) as some: some
case None: Some(0)
but it is longer and a bit noisier, but it would avoid an allocation. It would be nice to optimize the first into the second: namely, any values that are identical to parts of the match, just use the reference to the match instead.
Reactions are currently unavailable