Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
How to write the filter condition in ruby

I have some code logic which is written in javascript. I am new to ruby and I would like to write the same logic in Ruby. Here is the logic

var accountsToBlock = allExceedersArray.filter(accountId => !blockedExceedersArray.includes(accountId));
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Try something like this

accounts_to_block = all_exceeders_array.select do |account_id| 
  !blocked_exceeders_array.include?(account_id) 
end
about 4 years ago · Juan Pablo Isaza Report

0

ruby also has a filter method, but I would look at the ruby reject method, as it's more readable to say

all_exceeders.reject { |account_id| blocked_exceeders.include?(account_id) }

than

all_exceeders.filter { |account_id| !blocked_exceeders.include?(account_id) }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!