Feb 15, 2002, 4:48 PM
Post #10 of 12
Re: [Coderifous] I lended money to my 'coin'puter... (GOLF)
[In reply to]
Not only have I lost the ability to count, I embarrassed myself too. You have turned my brain to mush marcus. And I thought only my wife could do that.
I'm really sorry for that. I didn't mean to turn your brain to mush. Well, perhaps I did .
Nice use of ~~ It's a perl6 operator right?
No, but it looks pretty cool, eh?
What the hell does it do? I looked around a bit, but couldn't find anything significant on it.
It's actually no special operator (which means it's already available in Perl 5, otherwise my golf entry wouldn't be valid, as we don't play Perl 6 Golf yet). It's just the ~ operator (bitwise negation) applied twice. Damian Conway used this "operator" in his "Extreme Perl" talk I saw two days ago. He used it to force scalar context on an array to get its length. While you'd normally use scalar for that, you can use "~~". One "~" will force the scalar context and the other will just undo what the first one did. So what you get out is the length of the array. What I'm using it for is to force a floating point value into a integer. It works in exactly the same way, just that the "~" forces the conversion to an integer because bitwise operations can only be applied to integers.
At last with an effort he spoke, and wondered to hear his own words, as if some other will was using his small voice. "I will take the Ring," he said, "though I do not know the way."