On Jul 23, 2007, at 22:47 , Robert Stehwien wrote:

What is the source of the error produced by the following code?
----------
initialize
        table := OrderedCollection new.

        "there  are 100 entries like what is below"

        table add: ({
                #value->2.
                #cost->-3.
                #step->2.
                #defense->3.
                #combatMove->7.
                #fullMove->14.
                #carry->10.
                #lift->20.
                #death->20.
                #unconscious->11.
                #woundThreshold->4.
                #recovery->0.5.
                #mysticArmor->0.
        } as: Dictionary).
----------
More than 256 literals referenced.
You must split or otherwise simplify this method.
The 257th literal is: 4360
----------

I'm trying to create a data table for a program and I'm wondering if
I'm limited to 256 literals per class or method.  I tried initilizing
the table in multiple methods (setting 50 per method) but get the same
error.

The limit is 256 literals per method. However, a literal array is still just one literal. So you can put all your data into one literal if you want:

        #((
                value 2
                cost -3
                step 2
                defense 3
                combatMove 7
                fullMove 14
                carry 10
                lift 20
                death 20
                unconscious 11
                woundThreshold 4
                recovery 05
                mysticArmor 0
        ) (
                value 2
                cost -3
                step 2
                defense 3
                combatMove 7
                fullMove 14
                carry 10
                lift 20
                death 20
                unconscious 11
                woundThreshold 4
                recovery 05
                mysticArmor 0
        ) )

Then just iterate over it (#do: for the outer array, #pairsDo: is handy for the inner) to construct your objects. Btw, you surely would like to make a class and not just use dictionaries ;)

- Bert -


_______________________________________________
Beginners mailing list
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to