ruby - fastlane中的键值列表
问题描述
嗨,我编写了 fastlane 脚本,我需要在键值列表中。
我需要与键值在同一个列表中尝试键入:
default_platform(:android)
platform :android do
lane : getSomething do |options|
puts options[:type]
puts options[:whitelabel]
array={"samekey":"samevalue"}
array[:options[:whitelabel]]
end
end
我在哪里whitelabeloptions[:whitelabel] = samekey
出错
`[]': [!] 没有将 Symbol 隐式转换为 Integer (TypeError)
你有什么想法?
解决方案
主要原因:
key
有sym
类型,但我尝试搜索string
类型
所以解决方案:
default_platform(:android)
platform :android do
lane :getSomething do |options|
collection = { "key1":"value1",
"key2":"value2"}
key=options[:param1]
if collection [!key.to_sym].nil?
collection [key.to_sym].to_s
else
UI.user_error!("myMessage")
end
end
end
推荐阅读
- html - 要在网站上下载和使用的开源社交媒体图标?
- python - 将一种格式的日期转换为另一种格式
- php - 将搜索词添加到当前查询(Wordpress PHP)
- sql - 您可以使用 SSIS 循环播放单个文件吗?
- crash - 退出设置 MMF 的程序后,VB6 在 IDE 中崩溃
- c++ - 错误:没有运算符“==”与这些操作数匹配
- r - 在 x 轴上创建具有多个变量的条形图
- reactjs - 如何将 mongodb json 带到烧瓶中做出反应?
- amazon-web-services - 适用于 AWS Appflow 的 Amazon VPC 终端节点
- openstreetmap - 使用 osmnx 查找 OSM 边缘随时间的变化?