RUBY? Ruby? ruby? What's good style?
I know the answer—I just wanted to make sure the question was out there and questioners were aware that there is a correct form.
Also, should I capitalize "gem" as "GEM"?
class TestLanguageName < Test::Unit::TestCase
def test_language_name
assert_correct_language_name StackOverflow.new.describe_language("RuBy")
end
end
class StackOverflow
def describe_language(string)
# Which of the following?
methods = [:upcase, :capitalize, :downcase]
string.send(methods[rand(3)])
end
end
Ruby | String capitalize() Methodcapitalize is a String class method in Ruby which is used to return a copy of the given string by converting its first character uppercase and the remaining to lowercase. Parameters: Here, str is the given string which is to be converted.
Use capitalize . From the String documentation: Returns a copy of str with the first character converted to uppercase and the remainder to lowercase.
Section 1.9 of ruby-doc.org FAQ says:
Officially, the language is called "Ruby". On most systems, it is invoked using the command "ruby". It's OK to use ruby instead of Ruby. Please don't use RUBY as the language name. Originally, or historically, it was called "ruby".
Either Ruby or ruby is correct.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With