首页 > 解决方案 > 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)

你有什么想法?

标签: rubyfastlane

解决方案


主要原因: keysym类型,但我尝试搜索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

推荐阅读