forked from amber-smalltalk/amber
-
Notifications
You must be signed in to change notification settings - Fork 0
Accessing this recipe
Manfred Kröhnert edited this page Oct 22, 2013
·
1 revision
If you want to translate JavaScript functions to Amber calls there are two cases.
- If
this
gets accessed in a method it is referred to asself
. - Inside an Amber block closure it is impossible to get to true
this
. However, there is a transformation that allows you capturethis
as a block argument:
[ :thisarg :otherarg | ...code... ] currySelf
This produces a block that executes ...code...
but the first argument (thisarg
in the example) is not a 'real' argument any more. thisarg
captures this
and the first value the block gets evaluated with is stored in otherarg
.