What is idiomatic code?

后端 未结 5 900
时光说笑
时光说笑 2020-12-07 14:22

I\'d be interested in some before-and-after c# examples, some non-idiomatic vs idiomatic examples. Non-c# examples would be fine as well if they get the idea across. Thanks.

5条回答
  •  萌比男神i
    2020-12-07 15:14

    Idiomatic code is code that does a common task in the common way for your language. It's similar to a design pattern, but at a much smaller scale. Idioms differ widely by language. One idiom in C# might be to use an iterator to iterate through a collection rather than looping through it. Other languages without iterators might rely on the loop idiom.

提交回复
热议问题