Take a look at this VB.NET code:
list = GeoController.RegionByCountry(country, language)
Region.allByLanguage(key) = list
In C#, I could write this in one line:
Region.allByLanguage[key] =
(list = GeoController.RegionByCountry(country, language))
Is there a way to make this a one-liner in VB.NET, like I can in C#?
EDIT: You all must need some sleep, or else you might be thinking a little harder.
Region.allByLanguage is a cache.
Here's the context:
Dim list As IEnumerable(Of Region)
Dim key = Region.CacheKey(country, language)
If Region.allByLanguage.ContainsKey(key) Then
list = Region.allByLanguage(key)
Else
list = GeoController.RegionsByCountryAndLanguage(country, language)
Region.allByLanguage(key) = list
End If
Return list
How can you tell me that's not verbose code? Shudders.
Heck, if this was a C# team, I'd just write:
return Region.allByLanguage.ContainsKey(key) ?
Region.allByLanguage[key] :
(Region.allByLanguage[key] = GeoController.RegionsByCountryAndLanguage(country, language));
blah = (blah2 = blah())syntax? Who do you guys have to work with that this would be a readability issue? Poor fellas.(a > b? ((a > c) a : b ) : c). For the person writing the code, it's not hard to write, but it will need close examination for the reader to figure out what is going on.(Region.allByLanguage[key] = GeoController.RegionsByCountryAndLanguage(country, language))actually returns a value. Besides the VB.NET code is not verbose. It's as clear as daylight.