top | item 7444173

(no title)

jimhart3000 | 12 years ago

> Writing list(, $b) = array(3,4) is not allowed. Instead use $_, i.e.: list($_, $b) = array(3, 4).

Not that I think the former is good practice at all, but isn't the latter a kind of weird use of what is a valid variable name?

discuss

order

wting|12 years ago

Using _ as a throwaway variable name is idiomatic in Python, Haskell, and Go. Looks like they're pushing the same idiom in Hack, which I'm ok with.

agumonkey|12 years ago

AFAIK in Haskell it's not a throwaway variable, a pattern with _ will not create a binding at all. I don't think Python does this, maybe Go.

wycats|12 years ago

And Ruby, and Rust. It's close to universal.

underwater|12 years ago

It is a variable, not a language construct. The docs are just recommending `$_` as a convention over something like `$temp`.