Trouble. parse error

I have some problem when i want start program. What should I do to fix
this problem?
D:/2.rb:7: parse error, unexpected kEND, expecting $

r=10
R=20
h=30

def my_l = l(h, R, r)
Math.sqrt(h**2+(R-r)**2)
end # <= Here problem

def my_s = s(l, R, r)
Math::PI*3(R+r)+Math::PI(R2+r2)
end

def my_v = v(h, r, R)
Math::PIh/3(R2+r2+Rr))
end

puts l(10, 20, 30)

puts v(30, 10, 20)

puts s(my_l, 20, 10)

Vadim P. wrote in post #1035959:

def my_l = l(h, R, r)
Math.sqrt(h**2+(R-r)**2)
end # <= Here problem

To define and call a method, just write:

def l(h, r1, r2)
Math.sqrt(h**2 + (r1-r2)**2)
end

l(10, 20, 30)
=> 14.142135623730951

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