Very strange language choice for printing integer vs float arrays

singularity
Thu, 28 Jul 2022 22:12:45 +0000
General Usage

I find the following behavior of print statement quite strange.

Let’s say I have an array of floating point numbers and I print it. That is,

a = [2.0, 3.0]
println(a)

I get the following result upon executing the code above:

[2.0, 3.0]

However, if I do the same thing with an array of integers, I get this

b = convert.(Int32, a)
println(b)

This time I get the result

Int32[2, 3]

Why this inconsistency? Why is it showing the datatype now?

Thank you for your help.

3 posts - 3 participants