### Thread: Problem new to ruby?

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
2
Rep Power
0

#### Problem new to ruby?

# polynomial program :
class Term
attr_accessor: coeff, :sign
@@symbol
def initialization(Coeff)
@coeff = coeff
@sign = determine_sign(coeff)
end
private
def determine_sign(coeff)
mod = coeff.abs
if(coeff/mod)
return '+'
else
return '-'
end
# why it doesn't work??
end
class Poly
def initialization
@array = []
end

end
2. Please tell us what is wrong. What did you expect? what happened?

You can use code tags to keep the code formatting/indentation:
[code] insert code here [/code]
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Aug 2011
Posts
2
Rep Power
0
It doesn't work in the first place !
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2007
Location
India
Posts
3
Rep Power
0
After removing the syntax errors, here's your code:
Code:
```class Term
attr_accessor :coeff, :sign
@@symbol

def initialization(coeff)
@coeff = coeff
@sign = determine_sign(coeff)
end

private
def determine_sign(coeff)
mod = coeff.abs
if(coeff/mod)
return '+'
else
return '-'
end
end
end

class Poly
def initialization
@array = []
end
end```
Originally Posted by shehio
It doesn't work in the first place !
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
May 2007
Location
India
Posts
3
Rep Power
0
What do you want to achieve from your program?

Originally Posted by IndianGuru
After removing the syntax errors, here's your code:
Code:
```class Term
attr_accessor :coeff, :sign
@@symbol

def initialization(coeff)
@coeff = coeff
@sign = determine_sign(coeff)
end

private
def determine_sign(coeff)
mod = coeff.abs
if(coeff/mod)
return '+'
else
return '-'
end
end
end

class Poly
def initialization
@array = []
end
end```