[Activerdf] A resource or an array as returned object
Damaris Fuentes
dfl_maradentro at yahoo.es
Sun Apr 8 15:42:20 IST 2007
Hi you all,
I've realised (I dunno if this is the normal behaviour or I am doing something wrong) that if I ask for a set of resources with a property, the method returns either a resource or an array, depending on the number of objects obtained.
If a say:
dcsubject = RDFS::Resource('http://purl.org/dc/elements/1.1/subject')
@stuff = dcsubject.rdfs::seeAlso
and the "seeAlso" returns more than one resource, @stuff is an array with these elements. However, if the "seeAlso" property relates the subject with just one resource, "@stuff" is this resource.
So I cannot use the "for resource in @stuff do.." always. I just have to initialize @stuff as @stuff = [], and then add the possible resources, or just distinguish with an "if" clause if @stuff is one element or an array. Wouldn't it easier if the method returned always an array, even with one element?
Thanks :D
---------------------------------
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.deri.org/pipermail/activerdf/attachments/20070408/a78868ab/attachment.htm
More information about the ActiveRDF
mailing list