Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Foo() can have side-effects, taking a value from an array cannot, so Foo() is not necessarily dead code, whilst a[0] certainly is.

_ serves multiple purposes, not just for ignoring a return value. It's often used when you care about the side effect but not the return value, such as importation a driver for a database . You'll never use the library, so you import it as _ "db.driver.name/path/".



Can't taking a value from an array result in a panic? Quite the side effect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: