I’m in an introductory software development class, and my homework is to
create a rock paper scissors program that takes two arguments (rock,
paper), etc, and returns the arg that wins.
Now I would make quick work of this problem if I could use conditionals,
but the assignment says everything we need to know is in the first three
chapters of the ruby textbook, and these chapters DO NOT include
conditionals! Would it be possible to create this program without them?
Or is he just expecting us to be resourceful and use the conditionals.
It’s a very easy assignment with conditionals though…I’m thinking that
I might be missing something here.
conditionals! Would it be possible to create this program without
them?
Or is he just expecting us to be resourceful and use the
conditionals.
It’s a very easy assignment with conditionals though…I’m thinking
that
I might be missing something here.
I might be missing something here
Have you considered asking the professor/teacher/TA what their
expectations are? This can save you a lot of headaches, now and in the
future.
I leave the task of explaining this (and its origins) to your professor
to
yourself. Also, google for “church numerals” and “lambda calculus”–you
won’t
be disappointed!
It requires Ruby 1.8. It needs a few tweaks for the Ruby 1.9 series I
believe. It handles upper and lower case, and only uses the first letter
of each arg.
It is left as an exercise for the reader to explain why this actually
works.
For the assignment though, I’d probably use hashes as per Peter’s
suggestion.
Garth
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.