Is it possible to duplicate a float number array as a variable to a new variable in ruby with sketchup? I have tried both .clone and .dup, but no luck (see below).
a = [1.1,2.2,3.3]
b = [a.dup,a.dup,a.dup] #Returns "TypeError: can't dup Float"
b = [a.clone,a.clone,a.clone] #Returns "TypeError: can't clone Float"
Any other ways of duplicating an arrayed variable containing floats in ruby with sketchup?
EDIT: This is what I am trying to do:
a = [1.1,2.2,3.3]
x = [4.4,5.5,6.6]
b = [a,x]
b[0][1] += 1.1
b[1][1] += 1.1
so that a == [1.1,2.2,3.3]
, x == [4.4,5.5,6.6]
and b == [[1.1,3.3,3.3],[4.4,6.6,6.6]]
I now realise that both .clone and .dup work in Ruby itself (Thanks to Amadan and Sami Kuhmonen)
I can't see what your updated question has to do with the original one, but here's two ways to do what you wanted:
b = [a.dup, b.dup]
b[0][1] += 1.1
b[1][1] += 1.1
or
b.map! { |r| r.dup.tap { |r2| r2[1] += 1.1 } }