sawa sawa - 1 year ago 74
Ruby Question

Using `Array#[]` versus `find("...:nth-child(n)")`

When I want to pick up a certain node out of multiple nodes of the same type by its index, there are the following ways to do so:



Which way is better? Can you provide arguments with your preference?

Answer Source

find waits, all does not. Generally this means that find is less brittle (and superior). You should also be able to simplify the former to:

some_table_node.find("tr:nth-child(3) td:nth-child(5)")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download