Type Checking functions

For faster and efficient checking of the types of values, SRON provides 7 functions

  • is_void()

  • is_int()

  • is_double()

  • is_char()

  • is_bool()

  • is_collective()

  • is_string()

  • is_list()


1. is_void():

This function returns true if the passed value is Void otherwise false.

{
    name : Main
    Any val = Void

    if : {
        condition : is_void(val)
        println("Value is Void")
    }
    else : { 
        println("Value is not Void")
    }
}

OUTPUT:

Value is Void


2. is_int():

This function returns true if the passed value is of type 'Int' otherwise false.

{
    name : Main
    Any val = 27062003

    if : {
        condition : is_int(val)
        println("Value is an Integer")
    }
    else : { 
        println("Value is not an Integer")
    }
}

OUTPUT:

Value is an integer


3. is_double():

This function returns true if the passed value is of type 'Double' otherwise false.

{
    name : Main
    Any val = 2706.2003

    if : {
        condition : is_double(val)
        println("Value is a decimal number")
    }
    else : { 
        println("Value is not a decimal number")
    }
}

OUTPUT:

Value is a decimal number


4. is_char():

This function returns true if the passed value is of type 'Char' otherwise false.

{
    name : Main
    Any val = 'S'

    if : {
        condition : is_char(val)
        println("Value is a character")
    }
    else : { 
        println("Value is not a character")
    }
}

OUTPUT:

Value is a character


5. is_bool():

This function returns true if the passed value is of type 'Bool' Void otherwise false.

{
    name : Main
    Any val = false

    if : {
        condition : is_bool(val)
        println("Value is a boolean")
    }
    else : { 
        println("Value is not a boolean")
    }
}

OUTPUT:

Value is a boolean


6. is_collective():

This function returns true if the passed value is of type 'List' or 'String' otherwise false.

{
    name : Main
    Any val = [1, 2, true, [91, 92]]

    if : {
        condition : is_collective(val)
        println("Value is of collective type")
    }
    else : { 
        println("Value is not of collective type")
    }
}

OUTPUT:

Value is of collective type


7. is_string():

This function returns true if the passed value is of type 'String' otherwise false.

{
    name : Main
    Any val = "SRON"

    if : {
        condition : is_string(val)
        println("Value is a string")
    }
    else : { 
        println("Value is not a string")
    }
}

OUTPUT:

Value is a string


8. is_list():

This function returns true if the passed value is of type 'List' otherwise false.

{
    name : Main
    Any val = [1,2,3,4.177]

    if : {
        condition : is_list(val)
        println("Value is a list")
    }
    else : { 
        println("Value is not a list")
    }
}

OUTPUT:

Value is a list


Last updated