calendar:events uses reserved word #18

Closed
opened 2023-01-11 04:14:05 -05:00 by cuh7b5 · 1 comment
cuh7b5 commented 2023-01-11 04:14:05 -05:00 (Migrated from github.com)

The calendar event table format contains "end" representing the ending time of the event. This causes problems in further processing. This code gives an error because "end" is a reserved word in lua:

events = {}

function on_resume()
    local ev_titles = {}
    local ev_ends = {}

    events = slice(calendar:events(), 1, 10)

    for k,v in ipairs(events) do
        ev_titles[k] = v.title
        ev_ends[k] = v.end
    end

    ui:show_lines(ev_titles,ev_ends)
end
The calendar event table format contains "end" representing the ending time of the event. This causes problems in further processing. This code gives an error because "end" is a reserved word in lua: ``` events = {} function on_resume() local ev_titles = {} local ev_ends = {} events = slice(calendar:events(), 1, 10) for k,v in ipairs(events) do ev_titles[k] = v.title ev_ends[k] = v.end end ui:show_lines(ev_titles,ev_ends) end ```
zobnin commented 2023-01-11 04:48:55 -05:00 (Migrated from github.com)

Use v["end"]

Use `v["end"]`
Sign in to join this conversation.
No description provided.