Skip to content

Writeable variable outside function #209

@polarkac

Description

@polarkac

Is there a way to modify a variable that was defined outside a function? Its not that important but it could be useful in some cases. Or maybe I approach this in a wrong way.

For example:

#let total_hours = 0
#let work(hours) = {
    total_hours = total_hours + hours
    [#hours hours]
}

#table(
    columns: (auto, 1fr, auto),
    inset: 5pt,
    [*Name*], [*Desc*], [*Time*],
    "Work 1", "Work 1 desc", work(3),
)
Total hours: #total_hours

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions