zsh-users
 help / color / mirror / code / Atom feed
* arrays as arguments to functions
@ 2011-12-19 17:58 meino.cramer
  2011-12-19 18:13 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: meino.cramer @ 2011-12-19 17:58 UTC (permalink / raw)
  To: zsh-users

Hi,

is it possible to pass an array as an argument to a function and
if yes: How can I acchieve this?

Thank you very much for any help in advance!

Best regards,
mcc



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: arrays as arguments to functions
  2011-12-19 17:58 arrays as arguments to functions meino.cramer
@ 2011-12-19 18:13 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 2011-12-19 18:13 UTC (permalink / raw)
  To: zsh-users

On Mon, 19 Dec 2011 18:58:12 +0100
<meino.cramer@gmx.de> wrote:
> is it possible to pass an array as an argument to a function and
> if yes: How can I acchieve this?

It's not very comfortable: you just have to pass it by name and refer to
the variable by dereferencing the passed parameter.

% deref() { print ${(P)1}; print ${(P)1[-1]}; }
% array=(there once was a hacker named dave)
% deref array
there once was a hacker named dave
dave

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-19 18:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-19 17:58 arrays as arguments to functions meino.cramer
2011-12-19 18:13 ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).