w***@gmail.com

2014-11-14 21:03:37 UTC

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.

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.