[Newbies] Adding method to Smallinteger class

Herbert König herbertkoenig at gmx.net
Fri Apr 23 20:56:34 UTC 2010


Hi,

n>I have found some examples but they are a little too
n> complex for me to understand.....sorrry im being dumb...... the method I
n> would like to add would be called larger and would return larger of receiver
n> and parameter. Could someone please walk me through this step by step.

from the Menu bar, "Tools" get a Browser. Right click on the top left
pane, choose "find class" type in "Integer" and select "Integer". I
guess that's what you meant by "basic understanding of the
environment" but just in case...

In the third top pane click on "comparing", this is the proper
category for your lager: method.

In the bottom pane edit the template to:

larger: anInteger
  "return the larger of self and anInteger
  6 larger: 10
  "
  anInteger > self ifTrue: [^anInteger] ifFalse: [^self]


Right mouse click and choose "accept"

Then select the line 6 larger: 10, right click and select "print it".

n> for example.
n> 10 larger: 6
n> evaluates to 10


Then open a Workspace from the menubar and try your example.

HTH


Cheers,

Herbert   



More information about the Beginners mailing list