EngTW / English-for-Programmers

《程式英文》:用英文提昇程式可讀性
973 stars 45 forks source link

篩, 濾: filter, where #48

Open twy30 opened 4 years ago

LPenny-github commented 3 years ago

有些字帶有兩種正好相反的意思,如果缺少脈絡、註解、提示,容易造成誤解。

偶然看到的例子,或許可以參考?(書籍的格式比較好閱讀,所以以截圖的方式呈現 😅)

from 《The Art of Readable Code》

image

Aqzhyi commented 3 years ago

javascript, nodejs 開發者表示:「會是 <= 2011」

;[2012, 2011, 2010].filter(year => year <= 2011) // [2011, 2010]

然後 javascript, nodejs 開發者看到 ;[2012,2011,2010,null,undefined].filter(Boolean) 心裡又想 WTF?

twy30 commented 3 years ago

@LPenny-github 這讓我想到,