Swift blocks not working
问题 I've been trying to figure out how to use JavaScriptCore in swift. I'm running into problems however when I have to deal with blocks as arguments, seems like the block is run immediately and the arguments gets the return value of the block. What am I doing wrong? Working Objective C code: JSContext* context = [[JSContext alloc] initWithVirtualMachine:[[JSVirtualMachine alloc] init]]; context[@"test"] = ^(NSString *string) { //code }; What I've tried: 1: var ctx = JSContext(virtualMachine