I just fixed a funny bug where it was behaving very odd and it was because I had a return statement where I intended to have a continue. I musta looked at that line a dozen times and did not think anything of it. Just went back to the basics of debugging and ran through the code line by line, iteration by iteration. What an embarassing relief!
[Upon further reflection]
What if there was new language feature that made this less likely to happen. Does it help readability and/or intent? Take the following loop.
foreach (var i in theCollection)
{
if (i.Visible == false)
continue;
// other code goes here
}
What if I could change the syntax to something like this...
foreach (var i in theCollection)
except i.Visible == false
{
// other code goes here
}
Upon futher thought what if I just used LINQ instead?
var iVisible = theCollection.FindAll( i => i.Visible)
foreach( var i in iVisible)
{
// other code goes here
}
Not to bad from a syntax point of view. I don't like that I am making a shallow copy of the original list for the purposes of only iterating through it. The language extension above works on the original list.
Subscribe to:
Post Comments (Atom)
-
I keep looking for ways to leverage AI both at work and in my personal life. Recently, I asked for help rebalancing my portfolio. The follow...
-
Personal safety has changed for me. I have not posted much, if anything, about my experience as a transgender person. Mostly because I am a...
-
Since leaving Amazon, I have been recharging and considering what I want to take on next and with whom. I followed a similar process in 2013...
No comments:
Post a Comment