I need to duplicate a set of floating-point number variables.
See below for example:
x, y, z = 1.1, 2.2, 3.3
a = [[x.dup, x.dup, x.dup],[y.dup, y.dup, y.dup], [z.dup, z.dup, z.dup]]
This exact code works in Ruby itself, however in Sketchup, within the ruby console, this returns the following:
Error: #<TypeError: can't dup Float>
I have also tried .clone and that returns basically the same thing.
My reason for wanting to duplicate is so that if I run the following equation:
a[0][1], a[1][1], a[2][1] = a[0][1]+1.1, a[1][1]+1.1, a[2][1]+1.1
The results should be:
a == [[1.1, 2.2, 1.1],[2.2, 3.3, 2.2], [3.3, 4.4, 3.3]]
x == 1.1
y == 2.2
z == 3.3
Is there any way around this?
Edit:
What I was actually trying to do is this:
x, y, z = [1.1, 2.2, 3.3], [4.4, 5.5, 6.6], [7.7, 8.8, 9.9]
a = [x.dup, y.dup, z.dup]
And the results should be:
a == [[1.1, 3.3, 3.3], [4.4, 6.6, 6.6], [7.7, 9.9, 9.9]]
x == [1.1, 2.2, 3.3]
y == [4.4, 5.5, 6.6]
z == [7.7, 8.8, 9.9]