• Ultimate Guide to Ruby Strings

    From Jesus Castello@21:1/5 to All on Sun Feb 4 10:00:09 2018
    Hello!
    I wrote an article about ruby string methods on my blog rubyguides.

    You can read it here:

    http://www.rubyguides.com/2018/01/ruby-string-methods/

    Let me know what you think :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Fernando Basso@21:1/5 to Jesus Castello on Sun Jun 17 08:28:10 2018
    On 02/04/2018 04:00 PM, Jesus Castello wrote:
    Hello!
    I wrote an article about ruby string methods on my blog rubyguides.

    You can read it here:

    http://www.rubyguides.com/2018/01/ruby-string-methods/

    Let me know what you think :)


    Looks nice and useful. Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Klemme@21:1/5 to Jesus Castello on Thu Jul 5 09:10:51 2018
    On Sunday, February 4, 2018 at 7:00:17 PM UTC+1, Jesus Castello wrote:
    Hello!
    I wrote an article about ruby string methods on my blog rubyguides.

    You can read it here:

    http://www.rubyguides.com/2018/01/ruby-string-methods/

    Let me know what you think :)

    Looks good. Just a few minor nitpicks:

    My preferred method to test whether a string represents a number is to actually convert it and deal with the error:

    begin
    i = Integer(str)
    printf "%d\n", i
    rescue ArgumentError
    puts "Oh, it's not a number!"
    end

    Or

    i = Integer(str) rescue nil

    if i ...



    There is another way to extract a sub string:

    substr = str[/fo+/]

    and for replacing parts of the string:

    str[/fo+/] = "bar"

    (You'll get an IndexError if there is no match.)

    Cheers

    robert

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)