# if ((x = y) == z) 如標題所示,這篇打算講講這個寫法,如果詳細點,可以寫成 ```c= x = y; if (x == z) do_something(); ``` 這邊非常建議,**不要用這種寫法** 在C裡,這個寫法雖然很簡潔,但是出bug時非常難找到他。譬如說我寫成 ```c= if ((x = y == z)) do_something(); ``` compiler也是讓你過,在幾十甚至幾百行以上的程式碼裡根本就是大海撈針。 今天我就栽在這個坑裡,花了將近一個下午找出這個bug,整個下午都沒生產(氣 在這邊就我就覺得Golang設計的很不錯,將很多C裡很簡潔難懂的寫法都禁止了,雖然程式碼會變得更verbose一點,但讓可讀性增加,debug難度下降對於編程很有幫助。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up