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

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

SBM MODSCRIPT, PART 17 - File Fields
Submit a New Item from Chat in SBM 11.6

Related Posts

Comments

 
No comments yet

Recent Tweets