4D Blog

Home Product A wide range of possibilities to manage your collections

A wide range of possibilities to manage your collections

January 29, 2018

Product

4D v16 R6 provides advanced capabilities to manipulate collections, thanks to a series of methods to be used with Object Notation. Over 40 methods are now available, which allow, for example, the ability to add or remove elements in a collection, sort it, search the elements in it and much more! There are so many new possibilities that it is impossible to present them in a single post. This post is the first of a series you don’t want to miss…

How to call Collection methods?

A method associated to a collection is only accessible with Object Notation, thus it’s provided as a preview in 4D v16 R6 . The following example gives you some insight into what the code looks like . For instance, here’s how the push method allows you to add elements to the $col collection.

$col.push(10;100) // Add 10 and 100 to the collection
$s:=$col.sum() // Sum of all the elements of the collection
$r:=$col.pop() // Read and remove the last element

a Vast list of manipulations

  • Add elements: push, insert, unshift, resize and fill
  • Remove elements: pop, shift, remove and clear
  • Sort elements: orderBy, orderByMethod, sort and reverse
  • Calculate in collections: countValues, sum, average, count, min, max and reduce
  • Compare collections: equal
  • Copy and insert in collections: copy, concat, combine, slice and distinct
  • Search in collections indexOf, lastIndexOf, find, findIndex, filter, query, indices, every and some
  • Extract elements from collections: extract, map
  • Manipulate strings: Split string and join

To learn all the details about each method, take a look at the “collections” chapter from the language manual.

CONVERSION TO ARRAYS

For a smooth migration to collections, two new commands, COLLECTION TO ARRAY and ARRAY TO COLLECTION, have been created to help you to write new code alongside your existing code, and easily make them work together!

what’s next?

OK, it was a quite general post, but we had to give you the big picture before going further. The next blog post will go into more detail and demonstrate multiple ways to insert or remove elements from a collection.

Discuss

Tags Collections, Objects, v16 R6, v17

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy