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
Post a Comment