Possible Duplicates:
Check if Ruby object is a Boolean
How can I avoid truthiness in Ruby?

Given an array like the following (for example):

[3, false, "String", 14, "20-31", true, true, "Other String"]

Is there an easier way to determine which elements are actual boolean values without resorting to this, for example?

value === TrueClass || value === FalseClass

Relying on the position in the array is not an option, as it will vary from case-to-case.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top