Documentations - SRON
  • SRON's Official Documentation
  • Installation
  • Syntax of SRON
  • Executing a SRON code
  • Keywords in SRON
  • Comments in SRON
  • Datatypes in SRON
  • Variables in SRON
  • Memory Ownership Model
  • Operators in SRON
  • Math block
  • if elif else in SRON
  • Loops in SRON
    • For Loop
    • While Loop
    • Foreach Loop
  • Break & Continue
  • Functions in SRON
    • Print functions
    • User Input Functions
    • Type Conversion functions
    • Type Checking functions
    • Math functions
    • Char Functions
    • String Functions
    • List Functions
    • Miscellaneous functions
  • Return in SRON
  • Command Line Arguments
  • Free
  • Rotate
  • Console
  • Sample codes
  • Coding Convention
  • Frequently Asked Questions
  • Credits
  • Contact
  • Donate
Powered by GitBook
On this page

Return in SRON

If you want to return a value from a function, then 'return' attribute is used.

Below is a sample code:

{
    name : square
    args : (Int val)
    return : ~{ val^2 }~
}

{
    name : MAIN
    Int val = square(7)
    println(val)
}

You can return any datatype's variable from a function. You cannot return multiple values from a function. In order to do this, you can use 'List' like this:

{
    name : get_value
    return : ["Hello","SRON!"]
}

You can also set the return type of the function and for that you can use 'type' attribute. 'Type' attribute converts the return value to the specified datatype only if the datatype of returned value is not same.

{
    name : get_value
    type : Int
    return : 3.1415
}

SRON uses advance return value optimization to enhance code speed and efficiency. Even if the size of the value is too big, it doesn't affect the code performance.


PreviousMiscellaneous functionsNextCommand Line Arguments

Last updated 6 months ago