ModularM
Modular2y ago
16 replies
taalhaataahir01022001

Create 1D array of objects

How can I create a strcut which can create a 1-D array for HuffmanEntry shown in the example.

The copyinit function doesn't allow me to store data and gives the following error:

"error: no matching function in call to 'store': 
            self.data.store(i, elements[i])
            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/home/talha/Desktop/mojo/jpeg/C-code/Mojo/test.mojo:1:1: note: candidate not viable: method argument #1 cannot bind AnyRegType type to memory-only type 'HuffmanEntry'
struct HuffmanEntry(CollectionElement):
^
/home/talha/Desktop/mojo/jpeg/C-code/Mojo/test.mojo:1:1: note: candidate not viable: callee expects 2 arguments, but 3 were specified
struct HuffmanEntry(CollectionElement):
^
mojo: error: failed to parse the provided Mojo"
image.png
Was this page helpful?