Handling "Special" Cases in "Special" Ways
-
A sample of the code I'm working on now:
TimeZone = If(item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value <> "", item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value, "")
In short, set the result to the value when the value is not an empty string; otherwise, set the result to an empty string. :((
-
A sample of the code I'm working on now:
TimeZone = If(item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value <> "", item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value, "")
In short, set the result to the value when the value is not an empty string; otherwise, set the result to an empty string. :((
What language is that?
-
What language is that?
-
A sample of the code I'm working on now:
TimeZone = If(item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value <> "", item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value, "")
In short, set the result to the value when the value is not an empty string; otherwise, set the result to an empty string. :((
Something similar I catch myself almost writing is along the lines of:
if ( x <> y ) x = y
:sigh: -
A sample of the code I'm working on now:
TimeZone = If(item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value <> "", item.Descendants("DisplayableDateTime").Attributes("TimeZone").ElementAt(0).Value, "")
In short, set the result to the value when the value is not an empty string; otherwise, set the result to an empty string. :((
Are you by chance working in a funny language where
!(a<>b)
does not mean b can be used instead of a in all contexts? Let's say you have a language wherenull == ""
(for simplicity, you know?) Then you have an API that does not follow that convention and throws on a null.