Forum: Ruby easy question about inspect method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Les N. (Guest)
on 2006-04-07 05:00
When I use myarray.inspect, the result has some odd asymmetrical
formatting, like:
#nil, "role_id"=>"1", "last"=>"Normal", "first"=>"Norman", "id"=>"17"}>

what is the significance of the # at the start, and the } and > at the
end of this myarray.inspect result?

thanks in advance

Les
Robert D. (Guest)
on 2006-04-07 14:09
(Received via mailing list)
On 4/7/06, Les N. <removed_email_address@domain.invalid> wrote:
> Les
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Looks like
(1) myarray is an Object having an instance method being a Hash
(2) the # looks like a value of the hash is a method :nil
(3) and it looks like the output was cut before the "#"

There is an alternative of course:

class Array
   def inspect
       "#nil, "role_id"=>"1", "last"=>"Normal", "first"=>"Norman",
"id"=>"17"}>"
   end
end

which I consider unlikely

Cheers
Robert
--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein
Robert D. (Guest)
on 2006-04-07 14:12
(Received via mailing list)
Typo(1) myarray is an Object having an instance method being a Hash
==>
( 1) myarray is an Object having an instance being a Hash

How luck I proofread my posts after posting them, a practice I can only
reccommend.

Sorry for the noise
This topic is locked and can not be replied to.