Discussion:
parse error in a function
(too old to reply)
w***@gmail.com
2014-11-14 21:03:37 UTC
Permalink
I extended a gcd function for Integer class. Below is the content:

Integer extend [
gcd: anInt [
| x y |
(self < anInt)
ifTrue: [
x := anInt .
y := self .
]
ifFalse: [
x := self .
y := anInt .
]

[ (y=0) not ] whileTrue: [
|r|
r := x \\ y .
x := y .
y := r .
]

^x .
]
]

When I ran gnu on it, gnu complained that there is a parse error, and it expected ']' on line 14. Line 14 is this: [(y=0) not] whileTrue: [

Could anyway please help out? I am fairly new to smalltalk.
Joachim
2014-11-15 08:28:12 UTC
Permalink
I think you're missing a period at the end of line 12 ( the end of you ifTrue:ifFalse: send).

Joachim

Loading...