Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

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:






# Julia program to illustrate 
# the use of isvalid() method
   
# Getting true if the specified value
# is valid for its type else returns false.
println(isvalid(Char(2)))
println(isvalid(Char('a')))
println(isvalid(String("a")))
println(isvalid(SubString(String(UInt8[0xfe, 0x80]), 1, 2)))

Output:

Example 2:




# Julia program to illustrate 
# the use of isvalid() method
   
# Getting true if the specified value
# is valid for its type else returns false.
println(isvalid(Char, 0xd800))
println(isvalid(String, SubString("GeeksforGeeks", 1, 5)))
println(isvalid(Char, 'a'))

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :