-
Notifications
You must be signed in to change notification settings - Fork 2
executing scripts
sergeych edited this page Dec 27, 2014
·
1 revision
res = H8::Context.eval " ('hello' + ' world');" => 'hello world'
Or, more useful, create context object and manipulate it:
cxt = H8::Context
cxt[:hello] = 'Hey'
res = cxt.eval "last = hello + ' you';" => 'Hey you'
Note that as long as your H8::Context is not GC'd it keeps it state, in your case
res = cxt.eval 'last + "!";' # => 'Hey you!'
This way, you can keep contexts to store state between scripts and greatly improve script startup time (context creation is relatively heavy call, and, usually, you'll need to add some more initialization). But if you do keep contexts between script executions, bear in mind possibly memory load and leaks in it