Skip to content

prev()?.newValue() unavailable for add-multiple DSL #614

Open
@Jolanrensen

Description

@Jolanrensen

As is described here, adding a single column allows you to access the previous row with prev() and the new value of the previous row with prev().newValue<T>().

This enables:

df.add("fibonacci") {
    if (index() < 2) 1
    else prev()!!.newValue<Int>() + prev()!!.prev()!!.newValue<Int>()
}

I'd expect this to be equivalent:

df.add {
    "fibonacci" from {
        if (index() < 2) 1
        else prev()!!.newValue<Int>() + prev()!!.prev()!!.newValue<Int>()
    }
}

but unfortunately, since from {} provides a DataRow as context instead of AddDataRow, newValue() is unavailable.
I don't know whether this was done due to a technical limitation, but if it was an oversight it surely must be added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingresearchThis requires a deeper dive to gather a better understanding

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions