朱莉娅append!()无法将Char类型的对象转换为String类型的对象

布劳维尔特

我正在尝试将字符串添加到数组,如下所示:

arry = String[]
append!(arry, "test")

但出现以下错误:

Cannot `convert` an object of type Char to an object of type String

为什么添加字符串而不是字符时出现此错误?

(下面为其他Julia新手的利益发布了我自己的答案-有更多有用提示的人,请跳进来!)

BogumiłKamiński

我看不到您的答案,但这是典型的模式。

您可以push!单个元素或append!集合:

julia> arry = String[]
0-element Array{String,1}

julia> push!(arry, "test")
1-element Array{String,1}:
 "test"

julia> append!(arry, ("test",))
2-element Array{String,1}:
 "test"
 "test"

julia> append!(arry, ["test"])
3-element Array{String,1}:
 "test"
 "test"
 "test"

julia> append!(arry, Ref("test"))
4-element Array{String,1}:
 "test"
 "test"
 "test"
 "test"

注意,集合可以是例如a Tuple,aVectorRef(这是在广播中经常遇到的0维且非分配的集合)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

朱莉娅(Julia):无法将Array {Number,1}类型的对象转换为GLM.LmResp类型的对象

无法将 BitArray{1} 类型的对象“转换”为 Int64 类型的对象。朱莉娅

无法将 String 类型的对象转换为 Bitmap 类型

朱莉娅类型的问题

朱莉娅对象的地址

朱莉娅Excel对象

朱莉娅:我们可以改变不可变结构类型的对象多少?

将Person类型的对象转换为String()?

朱莉娅:将行向量转换为列向量

朱莉娅:将GIF帧转换为PNG

将数组转换为列表-朱莉娅

无法将类型为“ AttachmentDetailsDto”的对象转换为类型为“ System.String”的对象

无法将类型为“ System.Byte []”的对象转换为类型为“ System.String”的对象

SSIS:无法将“System.Decimal”类型的对象转换为“System.Char[]”类型

SSIS:无法将类型为“ System.Datetime”的对象转换为类型为“ System.Char []”

无法将Person类型的对象强制转换为PersonViewModel类型

朱莉娅列表理解更改类型

朱莉娅处理无效返回类型

朱莉娅抽象类型的优化?

朱莉娅,类型存储自己

朱莉娅,类型相互依赖

朱莉娅:不可变的复合类型

DatabaseException:无法将类型java.lang.String的对象转换为StreetClass类型

DatabaseException:无法将java.lang.String类型的对象转换为Models.OrderDetails类型

无法将java.lang.String类型的对象转换为com.mycare.OtherClass类型

无法将“System.String”类型的对象转换为“FileItem”类型

'无法将类型为'System.String'的对象转换为类型'System.Windows.Controls.ComboBoxItem

无法将“System.DateTime”类型的对象转换为“System.String”类型。C#

错误“无法将 java.lang.String 类型的对象转换为类型”