Wikis - Page

SBM MODSCRIPT, PART 18 - USING RANGE FOR EASY LIST INTERACTION

0 Likes

ChaiScript uses the "Range" object for iterating lists, Vectors, and Maps. Mainly, it does it behind the scenes while you use the for ( rec : list ) syntax. However, a Range can be a very useful way to quickly grab the first or last item in a list:

var firstField = range( rec.Fields() ).front();
var lastField = range( rec.Fields() ).back();

The above code creates a Range which wraps the list returned by rec.Fields().  The range can be used for iterating the list if desired, but the helpful hint here is how to access the first or last item in the list. 

 

SBM ModScript - Table of Contents

Tags:

Labels:

How To-Best Practice
Support Tips/Knowledge Docs
Comment List
Related
Recommended