Cannot find an initializer for type '[(String)]' that accepts an argument list of type '(LazyForward

Swift编译错误: Cannot find an initializer for type ‘[(String)]‘ that accepts an argument list of type ‘(LazyForwardCollection<MapCollectionView<Dictionary<Int,
String>, Int>>)‘

错误代码:

var dict = [1:
"m", 2:
"i", 3: "i",4:
"s"]

let dictKeysArray = [String](dict.keys)

根据字典字面量推断,该字典的类型是<Int: String>.即key为Int类型.错误的原因就是你用Int类型的初始化了key,现在又用String类型的取.所以会报该编译错误.

正确写法:

let dictKeysArray = dict.keys

或者将String改成Int.

版权声明:本文为博主原创文章,未经博主允许不得转载。

Cannot find an initializer for type '[(String)]' that accepts an argument list of type '(LazyForward

时间: 2024-08-06 11:58:00

Cannot find an initializer for type '[(String)]' that accepts an argument list of type '(LazyForward的相关文章

swift2.0 Cannot assign a value of type &#39;[CFString]&#39; to a value of type &#39;[String]&#39;

Cannot assign a value of type '[CFString]' to a value of type '[String]' 代码示例如下: picker.mediaTypes = [kUTTypeImage] 修改如下: picker.mediaTypes = [kUTTypeImage as String] swift2.0 Cannot assign a value of type '[CFString]' to a value of type '[String]'

CORE EF The expected type was &#39;System.String&#39; but the actual value was of type &#39;System.Guid&#39;.

[小提示]使用.NET Core EF 开发时,当你的数据库实体中添加了"Id"的字段时,会默认做为主键. 在设置数据库字段类型时如果设置了varchar或者char字段的长度为36时(36是微软GUID的长度),并且数据存储的数据正好是Guid字符串时,在使用EF查询数据库时EF会自动把数据类型转为Guid类型,如果你的数据库实体类中对应的字段正好是string类型时会抛出以下异常: An exception occurred while reading a database val

报错The &quot;chunk&quot; argument must be one of type string or Buffer. Received type object

报错内容: TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object at ServerResponse.end (_http_outgoing.js:690:13) 原因: response.end()方法接收的参数类型只能是字符串或Buffer, 传入的是object 解决: 找到代码出错行,重写end方法,如:r

Ant Design 中Select组件报错 Invalid prop `value` of type `string` supplied to `Select`

Invalid prop `value` of type `string` supplied to `Select`, expected `array` when `multiple` or `tags` is `true`. 这个位置默认值为数组 [ ] 原文地址:https://www.cnblogs.com/dianzan/p/12230353.html

Bitmap(Type, String) 图片路径

Bitmap(Type, String) 从指定的资源初始化 Bitmap 类的新实例. public Bitmap (Type type, string resource); 参数 type Type 用于提取资源的类. resource String 资源的名称. 示例 下面的代码示例演示如何从类型构造位图,以及如何使用 Save 方法. 若要运行此示例,请将代码粘贴到 Windows 窗体中. 处理窗体的 Paint 事件并调用 ConstructFromResourceSaveAsGif

解决warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’

[[email protected] c]# gcc MemTest.c -o MemTest1 -WallMemTest.c: In function 'main':MemTest.c:24: warning: format '%x' expects type 'unsigned int', but argument 2 has type 'int *'MemTest.c:39: warning: format '%x' expects type 'unsigned int', but arg

[WPF]The type name ‘App’ does not exist in the type &#39;...&#39;的问题

refer to: https://stackoverflow.com/questions/4480087/wpf-the-type-name-app-does-not-exist-in-the-type-occurs-after-renaming-mai 问题描述:当创建一个namespace名与class名相同的solution并编译时,可能遇到报错"The type name 'App' does not exist in the type '...'",如下图所示: 问题解决:

POSTGRESQL中ERROR: recursive query &quot;t&quot; column 2 has type character varying(150) in non-recursive term but type character varying overall

最近在做项目的时候有个需求是需要查到当前登录的用户下辖所有区域的数据,并将查询出来的部门信息以如下格式展示 最高人民法院>江苏省高级人民法院>南通市中级人民法院最高人民法院>江苏省高级人民法院>连云港市中级人民法院 ,于是用如下语句查询 WITH RECURSIVE T AS ( SELECT c_id, c_name FROM db_aty.t_aty_corp WHERE c_pid IS NULL UNION ALL SELECT D.c_id, T.c_name || '&

FutureWarning: Passing (type, 1) or &#39;1type&#39; as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / &#39;(1,)type&#39;.

关于报错信息 C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe E:/RBM_tf2.0_CNN/rmb_my/model_use.py C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\framework\dtypes.py:516: FutureWarn