Skip to content

Conversation

@prh90
Copy link

@prh90 prh90 commented Nov 24, 2016

@ssachid trying to use constants, can you help me understand the problem.

@prh90
Copy link
Author

prh90 commented Nov 24, 2016

@kenrett What we were talking about in tests and using constants

RESPONSE1 = "Listen, class, this is how everything works. "
RESPONSE2 = "*drops crazy knowledge bomb* "
RESPONSE3 = "... You're welcome."
TRAINING_SESSION_RESPONSE = "Whoa. I know ruby-fu"
Copy link

@ssachid ssachid Nov 29, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, you can also make a hash here with responses and their values.

response_hash = { response1: "Listen, class, this is how everything works. ", response2: .... }

@age = args.fetch(:age, 0)
@name = args.fetch(:name, "")
end
end No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation may seem trivial, as the program works whether you're following standard conventions or not. But when you're working on a large project with lots of other people, you want to know that everyone is following the same style guide. Even just looking back on your own code, you'll prefer well formatted code over poorly formatted code! And any workplace with code reviews in place will require that you follow their style guide, so get used to it now.

Make sure to set sublime (or whatever text editor you're using) to have 2-space tabs, since that's what we use in the files we give you, and we like consistency (also, sometimes if you have tabs in some places and spaces in others, it can look right to you, but then look wrong on github).

http://stackoverflow.com/questions/9474090/how-do-i-force-sublime-text-2-to-indent-two-spaces-per-tab

def offer_high_five
"High five!"
end
end No newline at end of file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

RESPONSE1 = "Listen, class, this is how everything works. "
RESPONSE2 = "*drops crazy knowledge bomb* "
RESPONSE3 = "... You're welcome."
TRAINING_SESSION_RESPONSE = "Whoa. I know ruby-fu"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constants should be used only when value cannot change during the execution of the script.
Where ever I see a constant I can be sure that its value was not changed anywhere along the way since it being defined.

For eg: the year you were born is a constant, while your postcode is an instance variable

end

end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants