Open In App

Getting data type of elements in Julia – typeof() Method

Last Updated : 26 Mar, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The typeof() is an inbuilt function in julia which is used to return the concrete type of the specified elements.

Syntax: typeof(x)

Parameters:

  • x: Specified element.

Returns: It returns the concrete type of the specified elements.

Example 1:




# Julia program to illustrate 
# the use of typeof() method
  
# Getting the concrete type of 
# the specified elements.
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:




# Julia program to illustrate 
# the use of typeof() method
  
# Getting the concrete type of 
# the specified elements.
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}


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads