Doubt with AS and dictionaries

Im trying to underestand the correct use of dictionaries and I havbe a doubt about the combination of classes and dictionaries. In my code, I have something like this:

class Entity {
 Node@ n; 
String Name;

class ListOfEntity {
Dictionary D;
Entity Find(String id)
 if (D.Exists(id)) {
  retval = entity();
  return retval;

After reading about handles, classes and such, I made myself a mess and now I dont know if that is the correct way to do it. Will Find() return a “pointer” to an Entity instance, or just a new copy of it? If id doesnt exists, what should I return? I have tried null, 0, and all of them produces an error.

Try something like:

Entity@ Find(String id)
    Entity@ retval;

    if (D.Get(id, @retval))
        return retval;

    return null;

Not totally certain it works out the box but should be close, if it doesn’t work try without the at symbol in the Get call.

Ok, no errors now. Im not so sure if it is working because I cant get the Entity instance, but I will work out that later at home.

You need to set it in a similar way if using handles.

Entity@ handle = Entity();

D.Set('id', @handle);
D['id'] = @handle;

See for an example, its practically the same we just changed the method names in urho: … onary.html.