Question: At present, is it possible to process a single input without going through a bunch of effort to non abritruly process that single input as multiple strings?
What I know of, there is:
x, y = raw_input(), raw_input()
print(x + y)
But this isn’t really what I’m wanting, if anything I want the inverse: I want to assign multiple strings from one input line.
Is this currently possible?
The ruby version is:
x, y = gets.chomp, gets.chomp
print x + y
When what I’m wanting is more like:
w = gets.chomp
x = w[0]
y = w[1]
z = w[2]
print x + y + z
But for entire words, not individual characters.
Alright got it, some nice people in Discord helped me figure it out. An example coming soon.
It’s still not ideal, as you have to keep two words you want processed as one word with a _ mark.
But it does its text parsing well enough.
print " >> "
string = gets.chomp
array = string.gsub(/\s+/m, ' ').strip.split(" ")
greeting = array[0]; player = array[1]
request = array[2]; item = array[3]
for_from = array[4]; neighbor = array[5]
place = array[6]; complement = array[7]
if greeting == "hello" and
player == "bob" and
request == "may_i" and
item == "have" and
for_from == "a_unicorn" and
neighbor == "from" and
place == "the_backyard" and
complement == "nice_shirt"
else
puts "Not understood"
end