Hi
x="abc"
x[0].upcase!
??? - can so explain that? # cant be more 'in place' !
# Shouldnt that be changed?!
Thx Berg
Hi
x="abc"
x[0].upcase!
??? - can so explain that? # cant be more 'in place' !
# Shouldnt that be changed?!
Thx Berg
Hi
x="abc"
x[0].upcase!
??? - can so explain that? # cant be more 'in place' !
# Shouldnt that be changed?!Thx Berg
The documentation for on String is pretty clear it returns a new String.
A String is not an Array of Char in Ruby.
-James
... and you could use #= to get the result you're expecting.
x = "abc"
x[0] = x[0].upcase
x
#=> "Abc"
By the way, if you want to "capitalize" strings in Ruby you could try
the tips at How to capitalize the first letter in a String in Ruby - Stack Overflow
Best regards,
Abinoam Jr.
2016-09-17 20:19 GMT-03:00 James Pacheco <james.pacheco@gmail.com>:
On Sat, Sep 17, 2016 at 4:15 PM A Berger <aberger7890@gmail.com> wrote:
2016-09-17 20:19 GMT-03:00 James Pacheco <james.pacheco@gmail.com>:
On Sat, Sep 17, 2016 at 4:15 PM A Berger <aberger7890@gmail.com> wrote:
Hi
x="abc"
x[0].upcase!
??? - can so explain that? # cant be more 'in place' !
# Shouldnt that be changed?!Thx Berg
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>The documentation for on String is pretty clear it returns a new String.
A String is not an Array of Char in Ruby.
-James
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
The documentation for on String is pretty clear it returns a new String.
A String is not an Array of Char in Ruby.
-James
On Sat, Sep 17, 2016 at 4:15 PM A Berger <aberger7890@gmail.com> wrote:
Hi
x="abc"
x[0].upcase!
??? - can so explain that? # cant be more 'in place' !
# Shouldnt that be changed?!Thx Berg
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>