获取格式为 ["example"] 的值

Getting value formatted as ["example"]

我正在使用 NET-LDAP API 在 Rails 上使用 Ruby:

@ldap.search( :base => @treebase, :filter => @filter ) do |entry|
  entry.cn

当我得到 entry.cn 值时,它的格式为 ["example"] 如何在没有字符 [" "]?

的情况下获取此值

["example"] 表示您有一个包含一个字符串的数组。

要获取 Rails 中数组的第一个元素,您可以调用:

["example"].first