Skip to content

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.

  1. If this gets accessed in a method it is referred to as self.
  2. Inside an Amber block closure it is impossible to get to true this. However, there is a transformation that allows you capture this 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.

Clone this wiki locally
You can’t perform that action at this time.