Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > [REXML] why not Element#[] ?

Reply
Thread Tools

[REXML] why not Element#[] ?

 
 
gabriele renzi
Guest
Posts: n/a
 
      07-23-2004
Hi gurus and nubys,

I was just wondering why access to attributes of an element is done
just via #attributes#[].
IMO it would be nice to have Element#[] like:

def [](k)
attributes[k]
end

and ditto for #[]=

Anyway, Sean Russel is my personal XML deity so if this is not allowed
there may be a reason: what is this reason?
 
Reply With Quote
 
 
 
 
Sean Russell
Guest
Posts: n/a
 
      07-26-2004
gabriele renzi <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> I was just wondering why access to attributes of an element is done
> just via #attributes#[].


Element#[] is already defined, since it is inherited from Parent. #[]
references all child nodes of an element except attributes.

> if this is not allowed there may be a reason: what is this reason?


It was, primarily, a design decision: either Element#[] references
nodal children, or Element#[] references attributes. I chose the
children.

--- SER
 
Reply With Quote
 
 
 
 
gabriele renzi
Guest
Posts: n/a
 
      07-27-2004
il 26 Jul 2004 09:06:38 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (Sean Russell)
ha scritto::

>gabriele renzi <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
>> I was just wondering why access to attributes of an element is done
>> just via #attributes#[].

>
>Element#[] is already defined, since it is inherited from Parent. #[]
>references all child nodes of an element except attributes.


oops, sorry I just took a look at the quick RDoc api and did not
thought of inheritance

>> if this is not allowed there may be a reason: what is this reason?

>
>It was, primarily, a design decision: either Element#[] references
>nodal children, or Element#[] references attributes. I chose the
>children.


well, sure now this makes sense, thanks a lot
 
Reply With Quote
 
Sean Russell
Guest
Posts: n/a
 
      07-27-2004
gabriele renzi <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>. ..
> >Element#[] is already defined, since it is inherited from Parent. #[]
> >references all child nodes of an element except attributes.

>
> oops, sorry I just took a look at the quick RDoc api and did not
> thought of inheritance


No problem. The fact that rdoc doesn't include inherited methods in
the class signature bites everyone, sooner or later, including me.


--- SER
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why :: ? Why not : ? Why not . ? <- less clutter ?!? Skybuck Flying C++ 16 08-25-2007 09:48 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
why why why does function not work Horace Nunley ASP .Net 1 09-27-2006 09:52 PM
Cisco 2611 and Cisco 1721 : Why , why , why ????? sam@nospam.org Cisco 10 05-01-2005 08:49 AM



Advertisments