I have these two pieces of code, wich one is more readable?
foreach
decimal technicalPremium = 0;
foreach (Risk risk in risks)
{
technicalPremium = technicalPremium + risk.TechnicalPremium;
}
return technicalPremium;
linq
return risks.Sum(risk => risk.TechnicalPremium);
Basically, the difference between English and English [CC] is that the closed-captions setting provides descriptions of sounds, such as gasps, and prompts as to who is speaking. They're often autogenerated and, in Squid Game's case according to one viewer, a closer match to the English dub than the English subtitles.
Closed Captions are the most common kind of captions, used by major broadcasters and video streaming services like Facebook Live, YouTube and Vimeo. Usually identified by a [CC] symbol in the corner of the screen, closed captions exist as a separate file, allowing the viewer to switch them on or off whilst watching.
Closed captioning displays the audio portion of a television program as text on the TV screen, providing a critical link to news, entertainment and information for individuals who are deaf or hard-of-hearing.
Closed captions are a text version of the audio content of a video. This includes spoken words, but also information about who is speaking and any sounds relevant to understanding context and meaning. For example: [laughter], [applause], [ominous music], the lyrics to a song playing in the background, etc.
If the team that works on the code knows what the Linq version does and knows its inner workings, then it is more readable.
Use whichever you prefer but hide it in a method:
return risks.SumTechnicalPremium();
Neither. The first one is more verbose and likely to be understood by everyone. The second one is more concise and easily understood by everyone with even a passing knowledge of linq.
I'd say you can base your choice on the environment you are in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With