Foreach Loop
'foreach' is a looping attribute which is used to linearly iterate over String or List type values.
SRON provides 'foreach' attribute to work on foreach loop. To provide the value and the variable, 'on' attribute is used.
Syntax of 'on':
on : variable_name , value_to_iterate_onExamples:
Correct Syntax:
on : (Any val, [1,2,3,4])
or
on : (val, "Saksham Rapid Object Notation")
-----------------
Wrong Syntax:
@ 'on' attribute expects a String or List type of value
on : val, 1234
or
@ 'on' attribute doesn't require one variable and one value
on : ("SRON")Sample Code to iterate over list using foreach
OUTPUT :
1 2 3 true <#-Void-#> [91, 92, 93]
Sample code to iterate over string using foreach
OUTPUT :
S R O N
Last updated