Functions with optional parameters (using list with string index) in the Ring programming langauge

Hello

We will learn how to define functions with optional parameters in the Ring programming language.

We can do that using list with string index

Example

MyFunc( [:x=10] )
MyFunc( [:x=10 , :z=20] )
MyFunc( [:x=10 , :y=20 , :z=30] )

 

Func MyFunc aPara
See “Output:” + nl
if aPara[:x] != NULL
see “x Value = ” + aPara[:x] + nl
ok
if aPara[:y] != NULL
see “y Value = ” + aPara[:y] + nl
ok
if aPara[:z] != NULL
see “z Value = ” + aPara[:z] + nl
ok

Output

Output:
x Value = 10
Output:
x Value = 10
z Value = 20
Output:
x Value = 10
y Value = 20
z Value = 30
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