Figuring out some basic arrays - Class to Class

So I am trying to return to a class, from another class, and have it use
the value of an array that I want it to.

Prompts the user to give a number, hence if action == “1” etc.

action = $stdin.gets.chomp
if action == “1”
return ‘Death.@@ways_to_die.index “0”’
elsif action == “2”
return ‘HiddenTrapdoor’
else
return ‘Death.@@ways_to_die.index “1”’
end

^^^I just winged it here. Feel free to criticize.

From the class it is returning to, ‘Death’
For the sake of space I changed the values in the array to basic
numbers.

class Death < Scene
@@ways_to_die = [
“0”,
“1”,
“2”,
“3”,
“4”,
“5”,
“6”
]

def enter()
case
when @@ways_to_die.index “0” == true
@@puts ways_to_die[0]
when @@ways_to_die.index “1” == true
puts @@ways_to_die[1]
end
end
end

I spent 15 hours yesterday learning about arrays, hashes and classes,
and I would like to know how to do this, if at all possible. Any
help/advice would be greatly appreciated.

It is not too simple to deduce which difficulties you are having. Only
the oddness of your code gives us indications that the concepts of
object orientation are the origin of your troubles.

Jason Montgomery wrote in post #1156457:

I spent 15 hours yesterday learning about arrays, hashes and classes,

There is one concept missing in the list, and it should not be the last
one: objects. My suggestion for you is to concentrate a little on
classes and objects in your study. arrays and hashes will explain
themselves quite naturally, afterwards.

In Ruby, everything is an object, arrays, hashes and classes inclusive.
This alone should be motivation enough. I use the word “concept” to
avoid talking about “code”, because that is what object-orientation is
all about: relations and interactions, not “code”.

Example 1. One “Scene” could use/include one or several “Death”-objects.
The uses of these two types in the program should be quite different but
you chose to make Death inherit from Scene…

Example 2. Of what use (real-world-wise) is a method enter() for a
Death-object? I would rather expect…, let’s say… strike() or spare()
while enter() should be a functionality of a Scene. Both should probably
live separately and not be bound by inheritance, which is really the
toughest kind of relationship, as it creates very specific
“object-families”. Most of the time, inheritance means obstructions and
we use it to dissipate any hope that an object could ever act in a
certain way, rather than to make believe it could…

and I would like to know how to do this, if at all possible. Any
help/advice would be greatly appreciated.

Whatever you try to achieve, I think you must first untangle the wires,
that you have plugged a little too hastily. :wink:

You, good sir, are a life saver. Thank you. I will admit I have been
rushing the learning process, and quite likely overstepped certain
aspects that are key to it. That is usually the case, quite easy to
think you are doing well when you know that errors are to be expected.

I appreciate that. Will be finding other sources of knowledge, as the
one I was using didn’t go far into it.