[Cuis-dev] creating a Dictionary

Mark Volkmann r.mark.volkmann at gmail.com
Sun Jul 7 17:04:05 PDT 2024


Jaromir, thanks so much for explaining that! Makes sense now.

On Sun, Jul 7, 2024 at 4:46 PM Jaromir Matas <mail at jaromir.net> wrote:

>
> On 07-Jul-24 11:06:12 PM, "Mark Volkmann via Cuis-dev" <
> cuis-dev at lists.cuis.st> wrote:
>
> It seems that `Dictionary newFrom:` works with a run-time literal Array of
> Association objects and does not work with a compile-time literal Array or
> Association objects. For example, this works:
>
> as := {#a -> 'apple'. #b -> 'banana'. #c -> 'cherry'}.
> d2 := Dictionary newFrom: as.
>
> but this gives the error "MessageNotUnderstood: Symbol>>key".
>
> as := #(#a -> 'apple' #b -> 'banana' #c -> 'cherry').
>
>
> as = #(#a #-> 'apple' #b #-> 'banana' #c #-> 'cherry')
>
> i.e. `as` is not an array of associations :) Literal array won't create
> the association objects, or better to say the compiler doesn't do compile
> time evaluation. Check
> https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/blob/master/Documentation/Technical/HitchHikersCompiler.md and
> scroll to `Compile Time Evaluation` section.
>
>
> d2 := Dictionary newFrom: as.
>
> Can someone explain why?
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
>

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240707/9b6576aa/attachment-0001.htm>


More information about the Cuis-dev mailing list