[rcr] epsilon string escaping in %W()

Discussion in 'Ruby' started by Simon Strandgaard, Aug 7, 2004.

  1. problem:

    often I use the %W(a b c d e f) for quickly making an array of strings.
    sometimes I need an empty string in that array, and I have to
    change the code into %W(a b c) + [''] + %W(d e f).
    which doesn't look nice.. and makes me do silly stuff instead.


    suggestion:
    It would be really nice if it was easier to make empty strings within %W.

    for instance slash E could be the empty string
    %W(a \E b) #=> ["a", "", "b"]

    If no spacing in between.. then output would simply be
    %W(a\Eb) #=> ["ab"]

    --
    Simon Strandgaard
     
    Simon Strandgaard, Aug 7, 2004
    #1
    1. Advertising

  2. On Saturday 07 August 2004 13:56, Simon Strandgaard wrote:
    > problem:
    >
    > often I use the %W(a b c d e f) for quickly making an array of strings.
    > sometimes I need an empty string in that array, and I have to
    > change the code into %W(a b c) + [''] + %W(d e f).
    > which doesn't look nice.. and makes me do silly stuff instead.
    >


    solution:

    dblack suggested %W(a b c #{} d e f)

    Thansk

    --
    Simon Strandgaard
     
    Simon Strandgaard, Aug 7, 2004
    #2
    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. Francois Grieu

    a flirt with epsilon

    Francois Grieu, May 4, 2004, in forum: C Programming
    Replies:
    0
    Views:
    336
    Francois Grieu
    May 4, 2004
  2. Francois Grieu

    A flirt with epsilon

    Francois Grieu, May 4, 2004, in forum: C Programming
    Replies:
    2
    Views:
    2,277
    CBFalconer
    May 4, 2004
  3. jacob navia

    The machine epsilon

    jacob navia, Jun 29, 2007, in forum: C Programming
    Replies:
    51
    Views:
    1,615
  4. jacob navia

    Machine epsilon: conclusion

    jacob navia, Jun 30, 2007, in forum: C Programming
    Replies:
    46
    Views:
    3,990
    those who know me have no need of my name
    Jul 3, 2007
  5. Tim Rowe

    sys.float_info.epsilon

    Tim Rowe, Feb 4, 2009, in forum: Python
    Replies:
    6
    Views:
    852
    Mark Dickinson
    Feb 5, 2009
Loading...

Share This Page