I just spent 40 minutes banging my head against a pointy sharp wall. I’m using NVelocity as my view engine on a Monorail project and couldn’t figure out how to access an element of a collection.
$collection[0] // Doesn't work $collection(0) // Nuh-uh $collection.[0] // Nope $collection.get(0) // As per Velocity Docs. Nope $collection.get_Item(0) // THIS WORKS!
Ok, so that’s incredibly not obvious. I couldn’t find any reference to it on the Castle Project Website, the Velocity docs the Castle site refers you to, or pretty much anywhere. I did find it in the google group though, but only after a lot lot lot of searching. So hopefully this will save someone out there a few minutes of their life.
Or maybe I should just switch to Brail.
$collection.get_Item(0)!!!!!!
sorta reminds me of C++ STL vectors
This is due to :
- lack of syntax in nvelocity
- class instance’s indexer being compiled as Item CLR property
- Instance properties being compiled as get_PropertyName and set_PropertyName CLR methods
Pingback: Prozac dosages.
Hi James, you just saved this person at least an hour of research. Thanks!
@TD:
Glad it helped someone!