Advanced Ruby Programming

Hi,

I have been using ruby for awhile, but I still know very little about it
:(.

Today I read the uri.rb file because I need to port a piece of Java code
to ruby. I found that I cannot understand uri.rb at all!

  1. what is the use of nested modules? i.e., why?

  2. What is the meaning of the following code? especially the “(?:” and
    "(?# 1:"?

    (#{PATTERN::SCHEME}): (?# 1: scheme)
    (?:
    (#{PATTERN::OPAQUE_PART}) (?# 2: opaque)

Could any expert here point me to the right direction? Where can I find
a book or online resource that explain these advanced topics?

Thanks a lot.

Sincerely,
Shannon

[…]

  1. what is the use of nested modules? i.e., why?

Separation of code?

  1. What is the meaning of the following code? especially
    the “(?:” and “(?# 1:”?
(#{PATTERN::SCHEME}):                (?# 1: scheme)
(?:
   (#{PATTERN::OPAQUE_PART})         (?# 2: opaque)

(?:…) and (?#…) are documented in the pickaxe.

Respectively they are ‘cluster’ (group without capturing),
and ‘embedded comment’.

cheers,

···


Iain.

Oh, that’s part of a regexp? Thanks a lot :slight_smile:

Shannon

···

On Thu, 28 Aug 2003 22:08:51 +0900 Iain Truskett spoon@dellah.org wrote:

[…]

  1. what is the use of nested modules? i.e., why?

Separation of code?

  1. What is the meaning of the following code? especially
    the “(?:” and “(?# 1:”?
(#{PATTERN::SCHEME}):                (?# 1: scheme)
(?:
   (#{PATTERN::OPAQUE_PART})         (?# 2: opaque)

(?:…) and (?#…) are documented in the pickaxe.

Respectively they are ‘cluster’ (group without capturing),
and ‘embedded comment’.

cheers,

Iain.


Xiangrong Fang xrfang@hotmail.com