All local vars from a method have a nil value when halt is launched

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

All local vars from a method have a nil value when halt is launched

gerard alis
This post was updated on .
Excuse me for my poor english.


I have a problem in Amber Smalltalk. When the next code is executed all method variables have nil value on debugger:

pvtGetWordFragments: aString regex: aStringRegex
       
        | wordFragmentRegex fragments formattedWord execResult |
 
        wordFragmentRegex := RegularExpression fromString: aStringRegex flag: 'g'.
       
        fragments := OrderedCollection new.
        formattedWord := aString trimBoth asLowercase.
 
        execResult := wordFragmentRegex exec: formattedWord.
 
        self halt.
 
        "Don't execute the next code. You need more classes..."
        (execResult notNil) whileTrue:[
 
            fragments add: (VRSWordFragment newFrom: formattedWord inPosition: (execResult index)).
            execResult := wordFragmentRegex exec: formattedWord.
        ].
 
        ^fragments.



aString have value 'terratremol'
aStringRegex have value 'que|què|qui|quí|gue|guè|gué|gui|guí'

That method returns a collection of matches from aString instance, but my problem, when run that on a Workspace, appears when I eval "formattedWord" and "fragments" than values is nil.

Regards


Reply | Threaded
Open this post in threaded view
|

Re: All local vars from a method have a nil value when halt is launched

gerard alis
Ufff, now works. I change () for [] in whileTrue

        "Don't execute the next code. You need more classes..."
        [execResult notNil] whileTrue:[
 
            fragments add: (VRSWordFragment newFrom: formattedWord inPosition: (execResult index)).
            execResult := wordFragmentRegex exec: formattedWord.
        ].
 
        ^fragments.