I want to declare a float variable, with which I will later do some computations. However, the interpretor infers the variable is an Array and will later produce an error when I try to use the variable as a float.
avg = 0.0, nr = 0
p "avg is #{avg.class} "
Outputs the following:
"avg is Array "
Your code doesn't do what you think it does, and it's easy to see:
> a=2, b=3
=> [2, 3]
> b
=> 3
> a
=> [2, 3]
Use separate statements for variables or use the following form:
avg, nr = 0.0, 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With