Skip to content

Instantly share code, notes, and snippets.

View sanderDijkxhoorn's full-sized avatar
🎯
Focusing

Sander Dijkxhoorn sanderDijkxhoorn

🎯
Focusing
  • ClickHere
  • Netherlands
View GitHub Profile
@sanderDijkxhoorn
sanderDijkxhoorn / ruby_array_filter.rb
Created October 6, 2024 19:10
Filtering an array in Ruby by character properties
# A simple implementation of character-based filtering in Ruby, covering different edge cases and use scenarios.
def filter_array(input)
# Filter array for numbers
num_array = input.select { |item| item =~ /\d/ }
# Filter array for capitals
capital_array = input.select do |item|
item =~ /^[A-Z]+$/ ? true : false
end.compact