Jump to content
Tommi Prami

Spring4D dictionary and record values

Recommended Posts

Hello,

I tried to port Generics.Colllections code to using Spting4D collections instead. 

I got the  "raised exception class EInvalidCast with message '"TMyRecord" is not a class type.'" exception, are the records at all supported, or I am doing something wrong.
 

Code somethin g like that.

FRecordCache.Add(LKEyString, LMyRecord);

Created this way:
FRecordCache:= TCollections.CreateDictionary<string, TMyRecord>([doOwnsValues])

 

Never mind, it was the doOwnsValues 😄

Edited by Tommi Prami

Share this post


Link to post

Owns values, means "collection is going to call free on every vamue when it is no longer held in the list". Which implies it needs to be an instance of a class. A record is not. 

  • Like 1

Share this post


Link to post

litlle bit offtopic, just curious, 
but what would be the (big) advantage of using Spring4D for collections instead of the "Built In" generics/collections from Delphi?,.

 

Share this post


Link to post
48 minutes ago, mvanrijnen said:

but what would be the (big) advantage of using Spring4D for collections instead of the "Built In" generics/collections from Delphi?

waiting for @Stefan Glienke to show up and answer this

  • Like 1

Share this post


Link to post

I wrote my own set of collections years ago to escape from the bugs in the RTL collections, but I suspect there aren't so many these days

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×