Skip to content

Instantly share code, notes, and snippets.

@vito
Created August 3, 2010 14:33
Show Gist options
  • Save vito/506471 to your computer and use it in GitHub Desktop.
Save vito/506471 to your computer and use it in GitHub Desktop.
Block@in-scope
(b: Block) in-scope :=
Object clone do: {
delegates-to: b
call := b scope do: b
call: vs := b scope do: b with: vs
}
the $ the
> x = 0
> [1, 2, 3] map: { n | x = x + n; x } in-scope
[1, 3, 6]
> x
6
> { 1 + 1 } in-scope contents -- delegates to the original, so this still works
[(1 + 1)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment