Professional Web Applications Themes

ruby 1.8.0 and =~ - Ruby

Hi, rubyists. I have been out of it for a bit and have just started plating with 1.8.0. I notice a new warning around =~ "warning: string =~ string will be obsolete; use explicit regexp" Can someone please tell me the easy way to redo the following? arr.each { |item| if item =~ /blah/ info = item.split(/:/) store[key] = "#{val}:#{info[1].strip}:" end } TIA, -- -mark. ---------------------------------------------------- Mark Probert [email]probertmNOSPAM_nortelnetworks.com[/email] Nortel Networks ph. (613) 768-1082 ---------------------------------------------------- All opinions expressed are my own and do not reflect in any way those of Nortel Networks....

  1. #1

    Default ruby 1.8.0 and =~


    Hi, rubyists.

    I have been out of it for a bit and have just started plating with 1.8.0.

    I notice a new warning around =~
    "warning: string =~ string will be obsolete; use explicit regexp"

    Can someone please tell me the easy way to redo the following?

    arr.each { |item|
    if item =~ /blah/
    info = item.split(/:/)
    store[key] = "#{val}:#{info[1].strip}:"
    end
    }

    TIA,

    --
    -mark.

    ----------------------------------------------------
    Mark Probert [email]probertmNOSPAM_nortelnetworks.com[/email]
    Nortel Networks ph. (613) 768-1082
    ----------------------------------------------------

    All opinions expressed are my own and do not
    reflect in any way those of Nortel Networks.
    Mark Probert Guest

  2. #2

    Default Re: ruby 1.8.0 and =~

    ----- Original Message -----
    From: "Mark Probert" <probertmNOSPAM_acm.org.web-hosting.com>
    Newsgroups: comp.lang.ruby
    To: "ruby-talk ML" <ruby-talkruby-lang.org>
    Sent: Monday, August 11, 2003 1:19 PM
    Subject: ruby 1.8.0 and =~

    >
    > Hi, rubyists.
    >
    > I have been out of it for a bit and have just started plating with 1.8.0.
    >
    > I notice a new warning around =~
    > "warning: string =~ string will be obsolete; use explicit regexp"
    >
    > Can someone please tell me the easy way to redo the following?
    >
    > arr.each { |item|
    > if item =~ /blah/
    > info = item.split(/:/)
    > store[key] = "#{val}:#{info[1].strip}:"
    > end
    > }
    No need to redo that one... the item on the
    right of =~ is a regex, not a string.

    Hal


    Hal E. Fulton Guest

  3. #3

    Default Re: ruby 1.8.0 and =~

    Hi,

    At Tue, 12 Aug 2003 03:19:29 +0900,
    Mark Probert wrote:
    > Can someone please tell me the easy way to redo the following?
    Enumerable#grep might make it easier a bit.

    arr.grep(/blah/) { |item|
    info = item.split(/:/)
    store[key] = "#{val}:#{info[1].strip}:"
    }

    --
    Nobu Nakada

    nobu.nokada@softhome.net Guest

Similar Threads

  1. Ruby/Ruby on Rails Syntax Highlight/Code completion
    By Cannikinn in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 1
    Last Post: September 22nd, 01:05 AM
  2. Replies: 0
    Last Post: November 1st, 05:21 PM
  3. Replies: 1
    Last Post: October 29th, 07:52 PM
  4. RubyConf, Ruby Central, Ruby Garden temporary outage
    By dblack@superlink.net in forum Ruby
    Replies: 1
    Last Post: September 10th, 03:46 PM
  5. [ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
    By guillaume.pierronnet@ratp.fr in forum Ruby
    Replies: 0
    Last Post: August 31st, 11:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139