Should go to list.  Sorry for replying wrong earlier.

----- Original message -----
From: Mark Volkmann <r.mark.volkm...@gmail.com>
To: Greg Reagle <greg.rea...@umbc.edu>
Subject: Re: [Fish-users] default function parameters
Date: Fri, 18 Aug 2017 17:46:42 -0500

But suppose I wasn't using a switch and I wanted to set the value of
$language to some default value inside the function.I'm new to fish, so maybe 
I'm not allowed to change the value of a
parameter like language.If that's the case, I'd like set a new variable (maybe 
lang) to either
$language if it's set or 'english' if it is not set.How can I do that?

On Fri, Aug 18, 2017 at 5:44 PM, Mark Volkmann <r.mark.volkm...@gmail.com> 
wrote:> Thanks so much Greg!
> 
> On Fri, Aug 18, 2017 at 5:43 PM, Greg Reagle
> <greg.rea...@umbc.edu> wrote:>> On Fri, Aug 18, 2017, at 18:25, Mark Volkmann 
> wrote:
>>  > What's the best way to provide a default value for a function
>>  > parameter? For example, suppose I have a function like this:
>>  >
>>  > function greet -a name language  switch "$language"    case
>>  > 'english'      echo 'Hello, '$name    case 'spanish'      echo
>>  > 'Hola, '$name    case '*'      echo unsupported language $language
>>  > end end
>>  >
>>  > If it is called with "greet Bob", I want language to default to
>>  > 'english'.
>>
>>  function greet -a name language        switch "$language"
>>  case spanish>>                          echo "Hola, $name"
>>                  case english '*'
>>                          echo "Hello, $name"
>>          end
>>  end
> 
> 
> 
> -- 
> R. Mark Volkmann
> Object Computing, Inc.
> 



-- 
R. Mark Volkmann
Object Computing, Inc.
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to