bsky
bsky

Reputation: 20222

Rails element added to a set is not found in the set

I am adding an element to a set and although the element can be found in the set later, the include? method returns false when I search for it.

@used_date_first.add(fe.time.beginning_of_day)
p "#{@used_date_first.include?(fe.time.beginning_of_day)}"

prints

false

The set is declared like this:

@used_date_first = Set.new

Upvotes: 0

Views: 16

Answers (1)

Arthur Frankel
Arthur Frankel

Reputation: 4705

I believe there's an issue with your 'fe' var.

If I do this:

x = DateTime.now.beginning_of_day
@used_date_first.add(x)
p "#{@used_date_first.include?(x)}"

it prints true

Upvotes: 1

Related Questions