Syntax

Ruby Select Items Syntax

In Ruby, select items: keeps items matching a condition — nums.select(&:even?)

Quick Answer

Syntax
nums.select(&:even?)
RubySyntax

Select Items

Code example
nums.select(&:even?)

Keeps items matching a condition.

Learn More

How to select items in Ruby

  1. Open your Ruby file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Ruby Select Items Syntax

Use nums.select(&:even?).

Related Syntax References

Frequently asked questions

What is the Ruby syntax for select items?

Use this pattern: nums.select(&:even?)

Can I copy this Ruby code example?

Yes. Use Copy code and adapt the example to your program.

Is this Ruby syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify