"Directly accessing" return values without referencing

Posted by undocumented feature on Stack Overflow See other posts from Stack Overflow or by undocumented feature
Published on 2010-03-24T17:26:38Z Indexed on 2010/03/24 17:43 UTC
Read the original article Hit count: 210

Look at this ruby example:

puts ["Dog","Cat","Gates"].1

This will output Cat as ruby allows me to directly access the "anonymous" array created.

If I try this in PHP, however:

echo array("Dog","Cat,"Gates")[1]

This won't work.

  • What is this called, not only concerning arrays but all functions?
  • Where else is it possible?

Feel free to change the question title when you know how this "feature" is called.

© Stack Overflow or respective owner

Related posts about syntax

Related posts about programming-languages