Open
Conversation
houndci-bot
reviewed
Jun 24, 2017
| # where 'special character' means anything apart from the letters | ||
| # a-z (uppercase and lower) or numbers | ||
| def check_a_string_for_special_characters(string) | ||
| /\W/ === string |
There was a problem hiding this comment.
Reverse the order of the operands /\W/ === string.
| # [1, 3, 5, 4, 1, 2, 6, 2, 1, 3, 7] | ||
| # becomes [1, 3, 5, 4, 1, 2] | ||
| def get_elements_until_greater_than_five(array) | ||
| array.take_while { |element| element <= 5} |
| # return the shortest word in an array | ||
| # return the longest word in an array | ||
| def longest_word_in_array(array) | ||
| array.max { |a,b| a.length <=> b.length } |
There was a problem hiding this comment.
Use max_by(&:length) instead of max { |a, b| a.length <=> b.length }.
Space missing after comma.
| # even numbers come first | ||
| # so [1, 2, 3, 4, 5, 6] becomes [[2, 4, 6], [1, 3, 5]] | ||
| def separate_array_into_even_and_odd_numbers(array) | ||
| [array.select { |el| el.even? }, array.select { |el| el.odd? } ] |
There was a problem hiding this comment.
Space inside square brackets detected.
| # turn a positive integer into a negative integer. A negative integer | ||
| # stays negative | ||
| def make_numbers_negative(number) | ||
| -(number.abs) |
There was a problem hiding this comment.
Don't use parentheses around a method call.
| # round up - so 'apple' becomes 'app' | ||
| def get_first_half_of_string(string) | ||
| midpoint = (string.length.to_f / 2).ceil | ||
| string[0...(midpoint)] |
There was a problem hiding this comment.
Don't use parentheses around a variable.
| # discard the first 3 elements of an array, | ||
| # e.g. [1, 2, 3, 4, 5, 6] becomes [4, 5, 6] | ||
| def all_elements_except_first_3(array) | ||
| array.select {|el| array.index(el) > 2 } |
| # don't reverse the array, but reverse every word inside it. e.g. | ||
| # ['dog', 'monkey'] becomes ['god', 'yeknom'] | ||
| def reverse_every_element_in_array(array) | ||
| array.map { |value| value.reverse } |
| @@ -1,152 +1,182 @@ | |||
| # keep only the elements that start with an a | |||
| def select_elements_starting_with_a(array) | |||
| array.select { |word| word[0].downcase == 'a' } | |||
There was a problem hiding this comment.
Use casecmp instead of downcase ==.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Corrects a couple of errors/typos in the questions.