-
Apr 16th, 2015, 11:12 AM
#1
[RESOLVED] ? Operator
Is the ? operator the same as the If operator in VB.Net?
IE - Does this:
Code:
Dim foo As Integer = If(1 = 2, 5, 10)
'Foo = 10
Translate to this:
Code:
int foo = (1 == 2) ? 5 : 10;
//Foo = 10
Last edited by dday9; Apr 16th, 2015 at 11:18 AM.
-
Apr 16th, 2015, 11:22 AM
#2
Re: ? Operator
That's a condensed if in Java. It looks like it is the same as in VB, but just in case, it is doing:
<if whatever> ? <then> : <else>
-
Apr 16th, 2015, 12:31 PM
#3
Re: ? Operator
Ok, that's what I figured. Thanks!
-
Apr 16th, 2015, 02:00 PM
#4
Re: [RESOLVED] ? Operator
"Condensed if" is made up terminology. Just see https://en.wikipedia.org/wiki/%3F:#Java for the skinny in brief.
-
Apr 16th, 2015, 07:35 PM
#5
Re: [RESOLVED] ? Operator
While condensed if may be made up terminology, if 90% of programmers use the term, it is correct to use when describing something. It's the exact reason something gets added to the dictionary -- common use.
Just like no one will know what you're talking about if you pronounce the .gif file extension as "jif."
-
May 10th, 2015, 11:39 AM
#6
Re: [RESOLVED] ? Operator
I know I'm a bit late. But this is called a Ternary operator.
If you find my contributions helpful then rate them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|