Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: arrays as arguments to functions
- X-seq: zsh-users 16649
- From: Peter Stephenson <Peter.Stephenson@xxxxxxx>
- To: <zsh-users@xxxxxxx>
- Subject: Re: arrays as arguments to functions
- Date: Mon, 19 Dec 2011 18:13:47 +0000
- In-reply-to: <20111219175812.GA2910@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: Cambridge Silicon Radio
- References: <20111219175812.GA2910@solfire>
On Mon, 19 Dec 2011 18:58:12 +0100
<meino.cramer@xxxxxx> 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@xxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author