There isn’t any way to tell from here, operators like << are just names
of
methods, so it can be defined however the author of the code wants. What
you
need to do is figure out what in_squad returns (p player.in_squad) and
then
look up the api for it (if it is a gem, you can do “$ gem server”, then
open
your web browser to localhost:8808)
From this syntax, what must I change to take a player from the team?
That is really strange. At first, I simply didn’t look closely enough at
that, and “fixed” it in my head so that it actually said
team << player.in_squad
Which I would read as “add this player to the team.” But your code looks
like “add this team to the player” or perhaps “give the player this team
on which to be.”
So I’m with Josh: in this case, “<<” does NOT mean “concatenate.” You’ll
have to read the docs or the code to figure out what it really does
mean, and whether or not any kind of ‘opposite’ method is available.
Now, if the object on the left were an array, then “<<” means “append,”
not “concatenate.” “Push” also means “append,” and the reverse process
is “pop.”
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)