On Sat, Oct 16, 2010 at 6:00 PM, Paul Roche <prpaulroche / gmail.com> wrote:

> But on a simple level......
>
>
> say in irb mode I did the following...
>
>
> name = "John"
>
> name << " Smith"
>
> => John Smith
>
>
>
> Would it be possible to take "John" or "Smith" from name?
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Yes, we can know this now that you say we are dealing with Strings. It would
not work, for example, with Arrays
name = "John"
lastname = "Smith"
name << lastname # => "JohnSmith"
name.chomp! lastname
name # => "John"

Note that chomp! will return nil in some situations, so don't rely on
assigning from it (if you want to do that, use the non-bang version)