Remove Duplicate Array Items



    Michael Born


    This one-liner takes a myArray input and processes it using a Java stream to remove all duplicate array elements. The result is returned as a native CFML array with full support for array methods, including array member functions like myArray.first().

    Shortcut: deduplicate

    Filename pattern: *.cfc,*.cfm

    arrayNew(1).append( createObject( "java", "java.util.Arrays" ).stream( &[USER_INPUT:myArray:default] ).distinct().toArray(), true );
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.