vala - genie HashTable of string, STRUCT -


note: question array, not [ array or genericarray ] code:

init     var h = new hashtable of string, int? (str_hash, str_equal)     h["a"] = int ({1, 2, 3})     h["b"] = int ({5, 6, 7})    // here: works fine      // error here:      // array concatenation not supported public array variables , parameters     h["a"].data += 4  struct int     data: array of int     construct (a: array of int)         this.data = 

how fix this?

not answer, alternative way express this:

init     var h = new hashtable of string, int? (str_hash, str_equal)     h["a"] = int ({1, 2, 3})     h["b"] = int ({5, 6, 7})     h["a"].append ({4})  struct int     data: array of int     construct (a: array of int)         this.data =     def append (a: array of int)         this.data = this.data + 

now there no mixing of "variables , parameters" going on anymore, solves compiler error original code triggering.

the problem results in compiler error:

resize_array.gs:14.21-14.33: error: incompatible operand         this.data = this.data + 

which can simplified code:

init     x: array of int = {1, 2, 3}     y: array of int = {4, 5, 6}     z: array of int = x + y 

which produces same compiler error.

resize_array.gs:21.23-21.27: error: incompatible operand     z: array of int = x + y 

i have added new question based on this:

how concatenate 2 arrays?

as turns out concating arrays (it works string though!) not trivial task in vala/genie.

see other question solutions on how this.

i'd use gee containers (if don't have call c functions need plain array).

the solution using array of int:

init     var h = new hashtable of string, int? (str_hash, str_equal)     h["a"] = int ({1, 2, 3})     h["b"] = int ({5, 6, 7})     h["a"].append ({4})  struct int     data: array of int     construct (a: array of int)         data = new array of int;         append (a)     def append (a: array of int)         data.append_vals (a, a.length) 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -