Functions – Predefined parameters or optional parameters in the Ring programming language

Hello

if you want to use predefined parameters or optional parameters
Just accept a list that works like hash/dictionary

Example

sum([ :a = 1, :b = 2])
sum([ :a = 1 ])
sum([ :b = 2 ])

func sum pList
if plist[:a] = NULL pList[:a] = 4 ok
if plist[:b] = NULL pList[:b] = 5 ok
see pList[:a] + pList[:b] + nl

Output
3
6
6
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s