How can I access GLib.HashTable in Genie? I am trying to write a handler method for libsoup HTTP server. The query parameter is a GLib.HashTable. When I try to access query e.g. with
def search_handler (server : Soup.Server, msg : Soup.Message, path : string,
query : GLib.HashTable?, client : Soup.ClientContext)
response_text : string = null
if query is not null && query.contains("expr")
response_text = get_search(query.get("expr"))
I got the error:
error: missing generic type arguments
response_text = get_search(query.get("expr"))
^^^^^
The only way I found is to make a new HashTable object:
p : GLib.HashTable of string, string = query
expr : string = p.get("expr")
What is the right way to handle this?
My be you can try with : dict of string,string
var d = new dict of string,string
d["one"]="1"
d["two"]="2"
print "%s",d["one"]
something like this
[indent=4]
init
var h = new HashTable of string, int (str_hash, str_equal)
h["foo"] = 123
h["bar"] = 456
foo ("foo", h)
def foo (key: string, hash: HashTable of string, int)
// PUT HASHTABLE IN THE END
if hash.contains (key)
stdout.printf ("%s => %i", key, hash[key])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With