diff options
author | Stanley Lim <slim679975@gmail.com> | 2019-11-21 10:54:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-21 10:54:24 -0500 |
commit | 2b1e1cca08eac0d4dc8f685dbe98d80683ca9d3a (patch) | |
tree | 460bb7d5cbc1141f8e710e3704f6d03dc25ea193 /groovy.html.markdown | |
parent | d4c5ff14cc8a0717f68746b4fe84cfb4efbdecf6 (diff) | |
parent | f1d03b0318a43441bb96bfdaabbd914eaa985879 (diff) |
Merge pull request #1 from adambard/master
Merging from master.
Diffstat (limited to 'groovy.html.markdown')
-rw-r--r-- | groovy.html.markdown | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/groovy.html.markdown b/groovy.html.markdown index efbb2b32..89ca973a 100644 --- a/groovy.html.markdown +++ b/groovy.html.markdown @@ -181,6 +181,21 @@ class Foo { } /* + Methods with optional parameters +*/ + +// A mthod can have default values for parameters +def say(msg = 'Hello', name = 'world') { + "$msg $name!" +} + +// It can be called in 3 different ways +assert 'Hello world!' == say() +// Right most parameter with default value is eliminated first. +assert 'Hi world!' == say('Hi') +assert 'learn groovy' == say('learn', 'groovy') + +/* Logical Branching and Looping */ |