vb.net - Nested inline if statement -
in vb .net possible use inline if
statements, this
if ret = "a" else ret = "not a"
i know possible nest these statements. know might not practice readability drops down...
if if b ret = "a & b" else ret = "a & not b" else ret = "not a"
which evaluated :
if if b ret = "a & b" else ret = "a & not b" end if else ret = "not a" end if
now if remove last else
statement, :
if if b ret = "a & b" else ret = "a & not b"
which :
if if b ret = "a & b" else ret = "a & not b" end if end if
so guess compiler finds else
, matches last openend if
in line, makes sense. question : possible change evaluation order ? mean possible else matched first if ?
so :
if if b ret = "a & b" end if else ret = "not a" end if
but inlined (something this, parenthesis added understand mean) :
if ( if b ret = "a & b" ) else ret = "not a"
i tried parenthesis or adding end if
provokes syntax errors, , couldn't find documentation this.
i'm not stuck anywhere , know might not prorgamming practice, wanted know (out of curiosity) if possible.
i know switch statements (i.e. test b before a), let's can't (a list , must tested nothing before b count example).
you this
ret = if(a, if(b, "a & b", "a & not b"), "not a")
personally, never understood need put in 1 line.
Comments
Post a Comment