No implicit conversion to float from string

I have this program where there is float numbers in x and y which are
then used to move a model to those coordinates.

    x = a[1]
    y = a[2]

    obj = Sketchup.active_model.selection[0]
    pt = obj.bounds.center.vector_to([x,y,0])
    tr = Geom::Transformation.translation(pt)
    obj.transform!(tr)

Ruby is giving me this error:

#<TypeError: no implicit conversion to float from string>

I tried to do x = a[1].to_s but still give me the same error

sorry i mean .to_f

On Thu, Mar 17, 2011 at 11:09 AM, stephanie borg [email protected]
wrote:

I have this program where there is float numbers in x and y

Are you sure?

x = a[1]
y = a[2]

puts x.class
puts y.class

Ruby is giving me this error:

#<TypeError: no implicit conversion to float from string>

I tried to do x = a[1].to_s but still give me the same error

Then it seems like you’d want to do x= a[1].to_f instead, yes?

yes thanks :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs