We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
IMHO someone should fix the ruby code, it's not very idiomatic. Using globals is not encouraged in ruby, and if they are used, they should be CamelCased and not Camel_Underscore_Cased. Instead of the current code:
# problem: uses global, does not use CamelCase and# does not use the regex primitiveRegex_Pattern='hackerrank'# problem: uses global, does not use CamelCaseTest_String=getsregex=Test_String.scan/#{Regex_Pattern}/# problem: does not use string embeddingprint"Number of matches : ",regex.length
I propose this code:
regex_pattern=/hackerrank/test_string=getsregex=test_string.scanregex_patternputs"Number of matches : #{regex.length}"
I think this change would make ruby users feel much more comfortable :) What do you think?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Matching Specific String
You are viewing a single comment's thread. Return to all comments →
IMHO someone should fix the ruby code, it's not very idiomatic. Using globals is not encouraged in ruby, and if they are used, they should be
CamelCased
and notCamel_Underscore_Cased
. Instead of the current code:I propose this code:
I think this change would make ruby users feel much more comfortable :) What do you think?