On Thu, 10 Mar 2022 19:07:06 -0800 Darren Duncan <darren@darrenduncan.net> wrote: > On 2022-03-10 6:36 p.m., demerphq wrote: > > Agreed. > > > > Fwiw The opposite outcome, forcing a value to be a number > > internally would be: > > > > $num = 0+$num; > > > > Although saying that I wonder what we do these days with > > > > $num += 0; > > > > I haven't checked but I hope the two produce the same outcome. > > I have zero doubt those produce the same outcome. Any "foo=" > operators are just shorthands for assigning the result of "foo", and > so the type of $num must be a number because "+" is the operation. > > BUT, strictly speaking, the equivalence is ACTUALLY these 2: > > $num = $num + 0; > > $num += 0; > > It gives the same result the other way only because + is commutative. These are all good ideas I can include in the unit tests for the new functions when I get around to writing them - perhaps later today even :) -- Paul "LeoNerd" Evans leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/Thread Previous | Thread Next