Skip to content

Instantly share code, notes, and snippets.

@paulbaumgart
Created September 22, 2010 21:35
Show Gist options
  • Select an option

  • Save paulbaumgart/592630 to your computer and use it in GitHub Desktop.

Select an option

Save paulbaumgart/592630 to your computer and use it in GitHub Desktop.
CPLogRegister(CPLogPrint);
@import <Foundation/Foundation.j>
@implementation Test : CPObject
{
CPNumber ivar1;
CPNumber ivar2;
}
- (void)trick:(JSObject)eval_func
{
ivar1 = ivar2 = 5;
eval("ivar1 = 6");
eval_func("ivar2 = 6");
CPLog(ivar1); // 6
CPLog(ivar2); // 5 ?!
}
@end
[[[Test alloc] init] trick:eval];
CPLog(ivar2); // 6 ... *shakes head*
CPLog(ivar1); // Error, as it should be.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment