C # LINQ for ruby ​​equivalent processing equivalent

I am new to ruby ​​development, and now I am working on a project in ruby ​​1.8.7 using rails 2.3.11, and I was wondering if there is an equivalent in this language for C # linq for collection manipulations such as where clause.

Thanks.

+6
source share
3 answers

Equivalent to where Linq in Ruby find_all

Check the documentation for the Enumerable Module for other features.

+4
source

You can do similar things, as in linq, one way or another the syntax is different. You should write something like this:

 a.select { |i| (do something with item i and decide whether it should be added to the output array or not by returning true or false) } 

Assuming a is an array, this code will return a new array containing the elements that passed your validation code.

Array Class Documentation

+1
source

the named areas may be what you are looking for ... I think that in rails 3.1 there is something else in the depth of "where" as well as the material.

0
source

Source: https://habr.com/ru/post/892588/


All Articles