Checking type validity of a value in Julia – isvalid() Method
Last Updated :
01 Apr, 2020
The isvalid()
is an inbuilt function in julia which is used to return true if the specified value is valid for its type. The type can be either AbstractChar or String or SubString{String}.
Syntax:
isvalid(value)
or
isvalid(T, value)
Parameters:
- Value: Specified value.
- T: Specified type.
Returns: It returns true if the specified value is valid for its type else returns false.
Example 1:
println(isvalid(Char( 2 )))
println(isvalid(Char( 'a' )))
println(isvalid(String( "a" )))
println(isvalid(SubString(String(UInt8[ 0xfe , 0x80 ]), 1 , 2 )))
|
Output:
Example 2:
println(isvalid(Char, 0xd800 ))
println(isvalid(String, SubString( "GeeksforGeeks" , 1 , 5 )))
println(isvalid(Char, 'a' ))
|
Output:
Share your thoughts in the comments
Please Login to comment...