使用Ruby

时间:2016-09-17 18:33:55

标签: ruby-on-rails ruby

我有这种格式的哈希数组,我想搜索深元素的索引。

[{:users => [{:admins => [:address, :stage]}]}, :client]我想要一个会返回元素索引的函数(如:stage

def return_index(array، value)
 return "" #the index even as a string. "[0][:admins][1]". I can use eval to find the index
end

1 个答案:

答案 0 :(得分:2)

string movie_name;

getline(cin,movie_name);

cout<< "Movie Name:         ";
cout<<"\"" <<movie_name << "\"\;