How do dictionary lookups work in IronRuby? -


i have line of ironpython code:

traits['strength'].score + traits['dexterity'].score 

traits defined such:

dim m_traits new dictionary(of string, trait) scope.setvariable("traits", m_traits) 

i translate ironpython code ironruby, i'm having trouble finding correct syntax.

in ruby (and ironruby), variables must begin lowercase letter. therefore, change traits variable traits make code works:

var engine = ironruby.ruby.createengine(); var scope = engine.createscope(); scope.setvariable("traits", traits);  dynamic result = engine.execute("traits['strength'].score + traits['dexterity'].score", scope); 

(this code works, checked).

by way, creating variable starts capital letter makes constant (that's how ruby works) , adding constant scope done in different way.


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -