How to run a function in ruby


How to run a function in ruby



So, this is already making me feel stupid, but I need the answer. I think I learnt it somewhere but I haven't used ruby in a while so I probably forgot.
I am trying to set an age inside of a function in ruby and then get the age displayed.


def set_age(new_age)
@age = new_age
end

def get_age
@age
end



But how do I get this code to run?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

iOS Top Alignment constraint based on screen (superview) height