Stream: helpdesk (published)

Topic: Function forcing an abstract type


view this post on Zulip Davi Sales Barreira (Oct 18 2023 at 12:16):

Friends, I have the following issue. I have a tree-like data structure where the leafs are all of an abstract type G.
Now, consider a variable x::A where A<:G.
The thing is that when I run a function such as x->x over the data structure, it returns values of type A, so that, for example, a vector previously of type Vector{G} becomes of type Vector{A}. Is there a way to avoid this?

view this post on Zulip Sebastian Pfitzner (Oct 18 2023 at 12:28):

is this an issue because you want to later push a y::B<:G into that vector? Anyways, I think you'll need to explicitly create a vector with eltype G here


Last updated: Nov 06 2024 at 04:40 UTC