mirror of
https://github.com/gnustep/libs-steptalk.git
synced 2025-02-21 02:31:01 +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 := STScriptObject scriptObject.
|
||||||
object setEnvironment:Environment.
|
object setEnvironment:Environment.
|
||||||
|
|
||||||
" This is the source of new method "
|
|
||||||
source := 'sayHi Transcript showLine: \'Hi.\'. ^self'.
|
|
||||||
|
|
||||||
" Get the proper engine "
|
" Get the proper engine "
|
||||||
engine := STEngine engineForLanguageWithName:'Smalltalk'.
|
engine := STEngine engineForLanguageWithName:'Smalltalk'.
|
||||||
|
|
||||||
|
" This is the source of new method "
|
||||||
|
source := 'sayHi Transcript showLine: \'Hi.\'. ^self'.
|
||||||
|
|
||||||
" Create method "
|
" Create method "
|
||||||
method := engine methodFromSource:source
|
method := engine methodFromSource:source
|
||||||
forReceiver:object
|
forReceiver:object
|
||||||
|
@ -26,7 +26,16 @@
|
||||||
" Add the method to the object "
|
" Add the method to the object "
|
||||||
object addMethod:method.
|
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! "
|
" Sent it! "
|
||||||
object sayHi.
|
object sayHi.
|
||||||
|
object sayHiTo:'GNUstep'.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue