Josh Cheek wrote: > There are a few things, notice the syntax highlighting on line 46, you > need > to either escape that apostrophe, or else wrap your string in double > quotes. O jeez, I did not even notice that I just changed it because I noticed I forgot the apostrophe. > But this is a little tricky. Your variable was initially a String, but > when > you assigned it the value of Math::PI, it became a Float. So that method > monkey? does not exist on for Floats. Since it is defined in the String > class, self will always be a string, so it can never be equal to > Math::PI I think I grasped that > terms of OO I'm sorry, in terms of what? > However, your monkey method would be much better served as a function > that > receives a value, because then it can receive any value at all (where > shouted? indicates the state of the string, monkey? does not, because a > Float is not a string). No I'm sorry I got lost there I am not entirely sure what the problem is. I expect it is my lack of knowledge and experience. > def monkey?( var ) > var != Math::PI && var != "BYE" > end So let me get this one straight. Doing it like this would mean that instead of calling monkey? on the variable i would call the variable on the monkey? method.? I'm sorry, I did not truly understand the difference in there would it not be the exact same thing? > if reply == (Math::PI) > puts 'Do you know when I was your age I was a model?' > reply = gets.chomp > end > which gets executed first, so really, reply will never be Math::PI when > it > gets to the reply.mokey? call, because this code will ensure that it > becomes > the input. Sorry it was giving me a problem where it met two conditions at once and I'm not sure anymore of the exact problem but in the end I needed reply to originally be out of the loop but still give me a one time input in the loop. I also did not want the one time input to accidently be entered so I just thought what is something no one will ever type in and Pi being a never ending number seemed like a really good idea. > Also, as far as using constants goes, Math::PI doesn't make a lot of > sense. > I understand thats the point of it ;) but I think a better choice would > be > to use a symbol. You can think of a symbol as a string with the As I said I did not want it to be accidently entered and being a gamer I know the lengths some people will go to to break the game. > later, seeing :uninitialized in all places where you currently have > Math::PI > will make a lot more sense. Hmm. So if i use :uninitialised then it doesnt really mean anything, its just like a, placeholder? if I were to input :uninitialized in the prompt would it still give the .monkey? call though? -- Posted via http://www.ruby-forum.com/.