Can ruby comment out a block of code???

Discussion in 'Ruby' started by Roseanne Zhang, Oct 14, 2006.

  1. It sounds pretty stupid, but I could not find a way to do it in Ruby
    yet.

    Such in C/C++/Java:
    /*
    This is all comments.

    This forum is connected to a mailing list that is read by thousands of
    people. Before you post, please use the FAQ, the Ruby documentation and
    Google to find an answer to your question. If you can't find an answer
    there, make sure to include all relevant information that is necessary
    to help you in your post.
    */

    Am I missing something???

    Help, please!

    --
    Posted via http://www.ruby-forum.com/.
     
    Roseanne Zhang, Oct 14, 2006
    #1
    1. Advertising

  2. On Oct 14, 2006, at 12:47 PM, Roseanne Zhang wrote:

    > It sounds pretty stupid, but I could not find a way to do it in Ruby
    > yet.
    >
    > Such in C/C++/Java:
    > /*
    > This is all comments.
    >
    > This forum is connected to a mailing list that is read by
    > thousands of
    > people. Before you post, please use the FAQ, the Ruby documentation
    > and
    > Google to find an answer to your question. If you can't find an answer
    > there, make sure to include all relevant information that is necessary
    > to help you in your post.
    > */


    Ruby's block comment looks like this:

    =begin

    We're in a comment here. Both the =begin and the =end must be the
    first elements on a line for this to work.

    =end

    James Edward Gray II
     
    James Edward Gray II, Oct 14, 2006
    #2
    1. Advertising

  3. Roseanne Zhang wrote:
    > It sounds pretty stupid, but I could not find a way to do it in Ruby
    > yet.
    >
    > Such in C/C++/Java:
    > /*
    > This is all comments.
    >
    > This forum is connected to a mailing list that is read by thousands of
    > people. Before you post, please use the FAQ, the Ruby documentation and
    > Google to find an answer to your question. If you can't find an answer
    > there, make sure to include all relevant information that is necessary
    > to help you in your post.
    > */
    >
    > Am I missing something???
    >
    > Help, please!
    >

    <do this>

    $ acroread Programming\ Ruby.pdf

    Search for =begin

    Page 218:
    </do this>

    Looks like a line starting with "=begin" and a line starting with "=end"
    will comment out a chunk of code.

    HTH
     
    M. Edward (Ed) Borasky, Oct 14, 2006
    #3
  4. James Gray wrote:
    > On Oct 14, 2006, at 12:47 PM, Roseanne Zhang wrote:


    > =begin
    >
    > We're in a comment here. Both the =begin and the =end must be the
    > first elements on a line for this to work.
    >
    > =end
    >
    > James Edward Gray II


    Huge Thanks!

    I believe I saw it once somewhere, but remembered it wrong.
    I wrote
    ==begin
    ==end

    and it dit not work. :(

    Stupid me!!!!


    --
    Posted via http://www.ruby-forum.com/.
     
    Roseanne Zhang, Oct 14, 2006
    #4
  5. James Edward Gray II wrote:

    > Ruby's block comment looks like this:
    >
    > =begin
    >
    > We're in a comment here. Both the =begin and the =end must be the first
    > elements on a line for this to work.
    >
    > =end


    Are there any plans on introducing shorter form in ruby 2?

    The form isn't that much of a problem, but the fact that something like
    that isn't possible

    puts "hey" =begin
    comment
    =end

    Esad
     
    Esad Hajdarevic, Oct 15, 2006
    #5
  6. --------------enig0BDFE7764808114629A7AD4E
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable

    Esad Hajdarevic wrote:
    > Are there any plans on introducing shorter form in ruby 2?
    >=20


    Using all pound signs is more common - I only see the =3Dbegin / =3Dend
    style for file headers. Just Learn To Use Your IDE/Editor, and use
    whicheverkeycombo it provides for line-commenting a paragraph, and
    letting you span such a comment over multiple lines easily. I -think-
    ruby-mode for Emacs supports auto-fill for that. Might be thinking of
    another language though.

    David Vallner


    --------------enig0BDFE7764808114629A7AD4E
    Content-Type: application/pgp-signature; name="signature.asc"
    Content-Description: OpenPGP digital signature
    Content-Disposition: attachment; filename="signature.asc"

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.5 (MingW32)

    iD8DBQFFMl20y6MhrS8astoRAvjqAJ98aYuVK26cNjaWtkBCrhTVA3gqdwCfWyl/
    H6lTDuur9i5LGdXT1BO77T0=
    =cEkr
    -----END PGP SIGNATURE-----

    --------------enig0BDFE7764808114629A7AD4E--
     
    David Vallner, Oct 15, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alec S.
    Replies:
    10
    Views:
    10,226
    Alec S.
    Apr 16, 2005
  2. Xah Lee
    Replies:
    3
    Views:
    565
    Jeff Shannon
    Jan 27, 2005
  3. Dan Jacobson
    Replies:
    2
    Views:
    152
    Dan Jacobson
    Sep 20, 2003
  4. PerlFAQ Server
    Replies:
    0
    Views:
    120
    PerlFAQ Server
    Feb 3, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    189
    PerlFAQ Server
    Apr 16, 2011
Loading...

Share This Page