develooper Front page | perl.perl6.language | Postings from December 2001

Re: Apropos of nothing...

Thread Previous | Thread Next
From:
Damian Conway
Date:
December 13, 2001 11:39
Subject:
Re: Apropos of nothing...
Message ID:
200112131939.GAA05153@indy05.csse.monash.edu.au

   > In the following code fragment, what context is foo() in?
   > 
   >     @ary[0] = foo()

Scalar context. @ary[0] is a single element of @ary.

To call foo() in list context use any of the following:

	(@ary[0]) = foo();	# Assign @ary[0] the first element returned
	@(@ary[0]) = foo();	#   "      "      "    "      "       "
	@ary[@(0)] = foo();	#   "      "      "    "      "       "
	@ary[0,] = foo();	#   "      "      "    "      "       "
	@ary[[0]] = foo();	#   "      "      "    "      "       "

	@ary[0] = @(foo());	# Assign @ary[0] a ref to the elems returned
	@ary[0] =()= foo();	#   "      "     "  "  "   "    "      "
	@ary[0] = [foo()];	#   "      "     "  "  "   "    "      "

Damian

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About