• Help with hash table syntax

    From hank.lenzi@gmail.com@21:1/5 to All on Fri Jan 28 16:37:07 2022
    Hello, eiffelers --

    I'm getting a syntax error at line 48 (I've flagged it with a comment), but I can't wrap my head around it. What's wrong?


    note
    description: "Summary description for {MONTH_OFFSET}."
    author: ""
    date: "$Date$"
    revision: "$Revision$"

    class
    MONTH_OFFSET

    create
    start

    feature
    start
    note
    goals: "[ Calculate the month offset ]"

    local
    month_offset_table: HASH_TABLE[INTEGER, STRING] -- in Eiffel, it's: [Value,Key]

    do
    create month_offset_table.make(12)
    month_offset_table.put (6, "jan")
    month_offset_table.put (2, "feb")
    month_offset_table.put (2, "mar")
    month_offset_table.put (5, "apr")
    month_offset_table.put (0, "may")
    month_offset_table.put (3, "jun")
    month_offset_table.put (5, "jul")
    month_offset_table.put (1, "aug")
    month_offset_table.put (4, "sep")
    month_offset_table.put (6, "oct")
    month_offset_table.put (2, "nov")
    month_offset_table.put (4, "dec")
    -- exhibit
    across month_offset_table as ic loop
    print (ic.cursor_index.out + ": ")
    print (ic.item.out + ", ")
    print (ic.key.out + "%N")
    end -- loop


    -- feature
    -- h.put (v, k)
    -- v := h.item (k) -- given k key (STRING type) it returns v value (INTEGER type)

    feature {NONE}
    fetch_value(key: STRING): INTEGER -- SYNTAX ERROR SIGNALED HERE
    -- access query (takes a STRING, returns an INTEGER)
    local
    value: INTEGER
    do
    value := month_offset_table.item(key)
    Return := value
    end
    end


    end -- class MONTH_OFFSET


    Thanks for any help.
    -- Hank

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Liberty Lover@21:1/5 to hank....@gmail.com on Wed Aug 10 05:33:30 2022
    On Friday, January 28, 2022 at 7:37:08 PM UTC-5, hank....@gmail.com wrote:
    Hello, eiffelers --

    I'm getting a syntax error at line 48 (I've flagged it with a comment), but I can't wrap my head around it. What's wrong?



    ...

    feature {NONE}
    fetch_value(key: STRING): INTEGER -- SYNTAX ERROR SIGNALED HERE
    -- access query (takes a STRING, returns an INTEGER)
    local
    value: INTEGER
    do
    value := month_offset_table.item(key)
    Return := value
    end
    end

    ...

    Thanks for any help.
    -- Hank

    You have two end keywords in the `fetch_value' feature. Also, the typical convention is: feature {NONE} -- Implementation

    No one seems to have answered you yet, and it has been quite a few months. Sorry for the delay.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)