Bug 471381

Summary: Default values on function parameters
Product: z_Archived Reporter: Julien Ponge <julien.ponge>
Component: GoloAssignee: Project Inbox <golo-inbox>
Status: NEW --- QA Contact:
Severity: normal    
Priority: P3 Keywords: investigate
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Julien Ponge CLA 2015-06-29 16:34:16 EDT
(from https://github.com/golo-lang/golo-lang/issues/189)

Wouldn't be nice to do

function split = |text, seperator=";"| {
...
}

require(split("foo;bar") is ["foor", "bar"], "Default separator value)
require(split("foo:bar", ":") is ["foor", "bar"], "Explicited defined separator value)

---- yloiseau commented on 2 Oct 2014

:+1:

---- jponge commented on 2 Oct 2014

Yeah, it would be nice :smile:

---- danielpetisme commented on 2 Oct 2014

ie. DIY isn't it ?

---- jponge commented on 2 Oct 2014

That would make a fun exercise :-)

---- danielpetisme commented on 2 Oct 2014

Sounds famimiar. You told me the dame with the string interpolation :smile:

---- yloiseau commented on 10 Oct 2014

You can already do

function split = |text, seperator| {
...
}

function split = |text| -> split(text, ";")

require(split("foo;bar") is ["foor", "bar"], "Default separator value)
require(split("foo:bar", ":") is ["foor", "bar"], "Explicited defined separator value)

:smile:

my 2cts

---- yloiseau commented on 23 Oct 2014

btw, having named arguments/parameters would also be nice, and seems to be a related topic.