Ad
  • Custom User Avatar
    oystercar ☃ ~
    10001 ◯ : coffee
    coffee> str = "The quick brown fox jumped over the lazy dog."
    'The quick brown fox jumped over the lazy dog.'
    coffee> str[1..]
    'he quick brown fox jumped over the lazy dog.'
    coffee> str[5..]
    'uick brown fox jumped over the lazy dog.'
    coffee> str[20..]
    'jumped over the lazy dog.'
    coffee> ending = 25
    25
    coffee> str[ending..]
    'd over the lazy dog.'
    coffee> ending = 3
    3
    coffee> str[-ending..]
    'og.'
    
  • Custom User Avatar

    oystercar ☃ ~ 10001 ◯ : coffee
    coffee> str = "The quick brown fox jumped over the lazy dog."
    'The quick brown fox jumped over the lazy dog.'
    coffee> str[1..]
    'he quick brown fox jumped over the lazy dog.'
    coffee> str[5..]
    'uick brown fox jumped over the lazy dog.'
    coffee> str[20..]
    'jumped over the lazy dog.'
    coffee> ending = 25
    25
    coffee> str[ending..]
    'd over the lazy dog.'
    coffee> ending = 3
    3
    coffee> str[-ending..]
    'og.'

    Hope that clears it up! :)

  • Custom User Avatar

    the str.length here is superfluous.
    str[-ending.length..] is ending would work the same.