<commit_before>import Var

class:Array() {
    ## TODO: add for Array ##
    # http://brizzled.clapper.org/blog/2011/10/28/a-bash-stack/

    ## TODO: implement indexing and converting to assoc
    # http://stackoverflow.com/a/14550606/595157

    extends Object

    private Var _storedVariableName

    methods
        Array::__constructor__() {
            local _storedVariableName="__oo__array_${this//./_}"
            $this._storedVariableName = "$_storedVariableName"
            Log.Debug oo: creating array [ $_storedVariableName ]
            declare -ga "$_storedVariableName"
        }

        ## use the array like this: "${!Array}"
        Array::__getter__() {
            echo "$($this._storedVariableName)[@]"
        }

        ## generates a list separated by new lines
        Array::List() {
            (
            IFS=$'\n'
            local indirectAccess="$($this._storedVariableName)[*]"
            echo "${!indirectAccess}"
            )
        }

        Array::Contains() {
            local realArray="$($this)"
            local e
            for e in "${!realArray}"
            do [[ "$e" == "$1" ]] && return 0
            done
            return 1
        }

        Array::Add() {
            declare -ga "$($this._storedVariableName)+=( \"\$@\" )"
        }

        Array::Merge() {
            $this.Add "$@"
        }
    ~methods

}<commit_msg>Array: last element methods<commit_after>import Var

class:Array() {
    ## TODO: add for Array ##
    # http://brizzled.clapper.org/blog/2011/10/28/a-bash-stack/

    ## TODO: implement indexing and converting to assoc
    # http://stackoverflow.com/a/14550606/595157

    extends Object

    private Var _storedVariableName

    methods
        Array::__constructor__() {
            local _storedVariableName="__oo__array_${this//./_}"
            $this._storedVariableName = "$_storedVariableName"
            Log.Debug oo: creating array [ $_storedVariableName ]
            declare -ga "$_storedVariableName"
        }

        ## use the array like this: "${!Array}"
        Array::__getter__() {
            echo "$($this._storedVariableName)[@]"
        }

        ## generates a list separated by new lines
        Array::List() {
            (
            IFS=$'\n'
            local indirectAccess="$($this._storedVariableName)[*]"
            echo "${!indirectAccess}"
            )
        }

        Array::Contains() {
            local realArray="$($this)"
            local e
            for e in "${!realArray}"
            do [[ "$e" == "$1" ]] && return 0
            done
            return 1
        }

        Array::Add() {
            declare -ga "$($this._storedVariableName)+=( \"\$@\" )"
        }

        Array::Merge() {
            $this.Add "$@"
        }

        Array::LastElement() {
            local realArray="$($this)"
            echo "${realArray[(${#realArray[@]}-1)]}"
        }

        Array::WithoutLastElement() {
            local realArray="$($this)"
            echo "${realArray[@]:0:(${#realArray[@]}-1)}"
        }
    ~methods

}
{'fraction_non_alphanumeric': 0.14884627884302892, 'fraction_numerical': 0.017224569385765356, 'mean_word_length': 1.7047451669595781, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6503814', 'n_tokens_mistral': 933, 'n_tokens_neox': 861, 'n_words': 175}