|
OriginalGriff wrote: Burn the heretic!
Crispy, I would suppose. (Sigh)
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
|
This solution was posted a bit ago.
http://www.codeproject.com/Feature/WeirdAndWonderful.aspx?fid=392254&select=4324500&fr=1#xx0xx[^] - This user, however, put the $ outside of the curly braces.
I actually end up doing what you could describe as the long-hand of the two options I suggested: reassigning the variables to non-array. There's method to this madness, though, as the data I usually work with is coming from a database and some amount of preprocessing is often necessary before it's ready for display.
The curly braces method, however, I'll keep in mind for there's places where readability would be improved.
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
I had an opportunity to check this out, and of course, it worked.
+5
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "As far as we know, our computer has never had an undetected error." - Weisert | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
<blockquote class="FQ"><div class="FQA">Andrei Straut wrote:</div>Full-fledged Java/.NET lover, full-fledged PHP hater.</blockquote>
You must separate things, try using Yii framework and see about good pratices on PHP.
PHP is very powerful depends on the way you use.
http://www.yiiframework.com/[^]
|
|
|
|
|
I don't like PHP either, but this looks like a simple matter of operator precedence to me.
The precedence of operators is well defined in PHP. +/-/. have higher precedence than ?:, so the outcome is IMO reasonable, and in no way weird.
Consider this: x == 2 ? 14 : 2 * 7. Would you expect "* 7" to be evaluated after the ?: in this case?
Some people recommend redundant parentheses precisely for avoiding such situations - it's not just a matter of correctness, it's also a matter of expressiveness - the variant without parantheses is potentially misleading, even when it's intended.
|
|
|
|
|
BobJanova wrote:
The PHP weirdness is that the ternary is a weak binding.
And it's left associative. Which means:
<?php
$i = 2;
echo ($i <= 3) ? "Three or less" :
($i > 3) ? "Over 3" :
"Whaaaat?";
outputs "Over 3" because it is interpreted as:
<?php
$i = 2;
echo (($i <= 3) ? "Less than three" : ($i > 3)) ?
"Over 3" :
"Whaaaat?";
|
|
|
|
|
Might work if the brackets are in the right place
(intval($header->getPlacedTimestamp() != 0)) ? 'Yes' : 'No';
should be
(intval($header->getPlacedTimestamp()) != 0) ? 'Yes' : 'No';
This is why I hate PHP sometimes. How the original code doesn't at least generate a warning is beyond me...
Need a mobile website? http://mobidoo.com.au
|
|
|
|
|
6 words you are dumb, sorry
|
|
|
|
|
Just reading through some javascript the other day when I found this gem.
function GetCursorPosition(node)
{
if (navigator.userAgent.toLowerCase().indexOf("opera") != -1) return 0;
Would now be a bad time to say that I found it here at CP?
+5 to the first person to correctly identify where!
|
|
|
|
|
enhzflep wrote: found it here at CP
Well, someone doesn't like Opera!
I wonder when this will be solved.
(Or if)
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
Are you talking about this[^]?
|
|
|
|
|
Nope, sorry.
hint: its neither an article nor a user submitted post...
|
|
|
|
|
YOu found it right here[^]
At least artificial intelligence already is superior to natural stupidity
|
|
|
|
|
CDP1802 wrote: I found it right here[^]
I don't know where you found it
Nope, ftfy too.
You've both had it in your browsers today...
|
|
|
|
|
enhzflep wrote: You've both had it in your browsers today...
Then it must be on the 'Reply to Message' page.
...
Yes, I found it.
|
|
|
|
|
Yep, tracks cursor position inside the textarea where i'm writing now (hm, i'm feeling watched). At first glance, seems to be responsible for checking if cursor position is inside a tag when copying and pasting code. I may be wrong, but this is what I got in 1 min or so
EDIT: Now, thanks to Jochen I actually took his suggestion, so the 5 should go to him
Full-fledged Java/.NET lover, full-fledged PHP hater.
Full-fledged Google/Microsoft lover, full-fledged Apple hater.
Full-fledged Skype lover, full-fledged YM hater.
|
|
|
|
|
That's close enough for me.
It's line 1,618 of Edit.aspx
|
|
|
|
|
Yep - that's exactly what it does. With the evolution of "security" in browsers, handling Paste events has become more and more painful, so much so that the only way I can reliably handle it is to watch every elephanting keystroke in order to work out when a Paste event has happened and what was Pasted.
Except that Opera totally screws it up. I gave up.
You should see the server-side comments...
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
What hasn't Opera screwed up?
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
That's close enough for me.
It's line 1,618 of Edit.aspx
|
|
|
|
|
Condensed and renamed to protect the guilty...
Public Sub TestThis(bFlag as Boolean, objVar as Object)
If (Not bFlag) And (bFlag <> Not CBool(objVar Is Nothing)) Then
End If
End Sub
I know the CBool is completely unneeded. But I'm having a heck of a time understanding what this little snippet was supposed to be testing for, or how it even came into existence in the first place. It seems like it would be cleaner to just test:
(Not bFlag) And Not (objVar Is Nothing)
There are actually several other instances of this kind of test that I think are just there for a confusion factor. They all follow the same basic pattern of:
(Not boolean1) And (boolean1 <> boolean_test_condition)
In order for the whole test to be True, the first Boolean must be False, so boolean test condition on the right side MUST be True. Why even bother comparing the test condition result against the first value?
(Not boolean1) And boolean_test_condition
I'm so ripping my hair out every time I have to dive into legacy code like this. Good thing it's Friday!
|
|
|
|
|
public void WriteCode(ICodeContext ctx)
{
throw new BrainNotFoundException();
}
Bill Gates is a very rich man today... and do you want to know why? The answer is one word: versions.
Dave Barry
Read more at BrainyQuote[ ^]
|
|
|
|
|
That's called obfuscation.
Theoretically, it could be intended (protection against reverse engineering, or just abuse of the colleagues who have to maintain that code).
But more often, it happens due to other factors. E.g. the law of thermodynamics: things get worse under pressure. Or medical conditions like hypocaffeinemia.
|
|
|
|
|
Select Case ListIT
Case 1: nList = oArti.List1
Case 2: nList = oArti.List2
Case 3: nList = oArti.List3
Case 4: nList = oArti.List4
Case 5: nList = oArti.List5
Case 6: nList = oArti.List6
Case 7: nList = oArti.List7
Case 8: nList = oArti.List8
Case 9: nList = oArti.List9
Case Else
nList = 1
End Select
I think, array is a vulgar word for someone. Funny thing, I didn't understood what in the name of lord does that (variables were not descriptive about content they have) Also, funny comments! (code was originally written in spanish)
|
|
|
|