mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-19 09:50:43 +00:00
updated example
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/steptalk/trunk@17442 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c8d3797f86
commit
65335eb012
1 changed files with 12 additions and 3 deletions
|
@ -12,12 +12,12 @@
|
|||
object := STScriptObject scriptObject.
|
||||
object setEnvironment:Environment.
|
||||
|
||||
" This is the source of new method "
|
||||
source := 'sayHi Transcript showLine: \'Hi.\'. ^self'.
|
||||
|
||||
" Get the proper engine "
|
||||
engine := STEngine engineForLanguageWithName:'Smalltalk'.
|
||||
|
||||
" This is the source of new method "
|
||||
source := 'sayHi Transcript showLine: \'Hi.\'. ^self'.
|
||||
|
||||
" Create method "
|
||||
method := engine methodFromSource:source
|
||||
forReceiver:object
|
||||
|
@ -26,7 +26,16 @@
|
|||
" Add the method to the object "
|
||||
object addMethod:method.
|
||||
|
||||
" Add another method with an argument "
|
||||
source := 'sayHiTo:someone Transcript showLine: (\'Hi \', someone). ^self'.
|
||||
method := engine methodFromSource:source
|
||||
forReceiver:object
|
||||
inEnvironment:Environment.
|
||||
object addMethod:method.
|
||||
|
||||
|
||||
" Sent it! "
|
||||
object sayHi.
|
||||
object sayHiTo:'GNUstep'.
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue