Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用MySQL2 Ruby 驱动程序-但调用似乎有点多余
result.each{ |r| puts r['name'] }
对于返回的单行数据。必须有一种更简单的方法来获取我想要的mysql字段而不必使用each块?
each
你result应该是一个Mysql2::Result,Enumerable这样你就可以在上面使用first(和其他Enumerable好东西):
result
Mysql2::Result
Enumerable
first
puts result.first['name']