[thelist] Assignment Question

Jason Handby jason.handby at corestar.co.uk
Fri Sep 10 11:32:56 CDT 2010


> > I figured most languages(i'm not gonna say all) would be the same
for
> assignment ops.
> 
> I've programmed in many languages, but not PERL, and:
> 
> 1. Assignment ops do vary, depending upon language, more than you'd
> think.
> 2. I've never seen a "|=" operator.
> 3. I'm guessing "a |= b" might mean "a = a | b", like C's "+="
> operator.

C, C++, C#, Java, Javascript and PHP all have the "|=" operator, and
yes, that's what it means.

I guess a use case would be if you were iterating through some bit
patterns and combining them into a bitmask - you'd start with 0, and
repeatedly bitwise-OR into it. Probably not the sort of thing web
developers do a lot though!


Jason



More information about the thelist mailing list