Getting data type of elements in Julia – typeof() Method
Last Updated :
26 Mar, 2020
The typeof()
is an inbuilt function in julia which is used to return the concrete type of the specified elements.
Syntax: typeof(x)
Parameters:
Returns: It returns the concrete type of the specified elements.
Example 1:
a = 1 / / 2 ;
b = 1 / 2 ;
c = 7 % 2 ;
d = 2 ;
println(typeof(a))
println(typeof(b))
println(typeof(c))
println(typeof(d))
|
Output:
Rational{Int64}
Float64
Int64
Int64
Example 2:
a = [ 1 , 2 , 3 , 4 ];
b = [ 1 2 ; 3 4 ];
c = [ 1 2 ; 3.5 4 ];
d = [ 1 2 ; 3 4 ; 5 4 ];
println(typeof(a))
println(typeof(b))
println(typeof(c))
println(typeof(d))
|
Output:
Array{Int64, 1}
Array{Int64, 2}
Array{Float64, 2}
Array{Int64, 2}
Share your thoughts in the comments
Please Login to comment...