I have an HTML document and I need to examine if any attribute is represented in the element in question
Suppose the attribute is not represented.
When I speak:
elem.has_attribute? "data-attr"
it returns nil instead of "false".
When I speak:
elem["data-attr"].nil?
it returns true, this is what I need.
But when I say:
!elem["data-attr"].nil?
repeats zero again.
When I speak:
r = elem["data-attr"].nil?
r = !r
r gets "true" after the first line
but after the second line "r" again gets zero
What kind of magic is behind?
source
share