Search code examples
smalltalksqueak

method that accepts a block and the block accepts an argument


How can I send a block and its argument to a method ? so the method receive the block and the block receives the argument and I run the block in the method iteslf...


Solution

  • Just pass the block and its argument to the method as separate arguments. Then send #value: to the block to pass the argument to the block. E.g.

    methodTaking: aBlock and: anArgument
      aBlock value: anArgument.
      ...