I always use @_[0] to get the first parameter and use @_[1] to get the second one. But when I search up code snippets online, I find many people like to use the shift keyword. I don’t find the shift keyword being intuitive at all. Is there any functional differences between these two?
I always use @_[0] to get the first parameter and use @_[1] to get
Share
Yes, there is a difference between the two.
shiftwould change the@_(You could argue this would be an operation that would make shift slower)
$_[0]or$_[1]is just assignment and would not change@_at all.The aesthetic way of writing this is :