my_basic
my_basic copied to clipboard
Dict item not printed
When a var is defined as a dict() in a class, printing a value from it can print the variable type followed by an error. Here's some sample code:
class request
var headers = dict()
var cookies = dict()
def sendheaders(s)
print get(headers, s) + chr(10)
enddef
def sendbody(s)
enddef
def sendstatus(s)
enddef
endclass
d = dict()
d("testing") = "123"
print "1: " + d("testing") + chr(10)
print "2: " + get(d, "testing") + chr(10)
print d("testing") + chr(10)
req = new(request)
req.headers("testing") = "123"
h = req.headers
print "3: " + h("testing") + chr(10)
print "4: " + get(h, "testing") + chr(10)
print h("testing") + chr(10)
print "5: " + req.headers("testing") + chr(10)
print "6: " + get(req.headers, "testing") + chr(10)
' This fails with:
'
' DICT
' Error:
' Ln 34, Col 17
' Code 30, Abort Code 3
' Message: Comma or semicolon expected.
print req.headers("testing") + chr(10)
Running this produces:
1: 123
2: 123
123
3: 123
4: 123
123
5: 123
6: 123
DICT
Error:
Ln 42, Col 17
Code 30, Abort Code 3
Message: Comma or semicolon expected.
Temporarily use print get(req.headers, "testing") + chr(10) instead. I'll refactor the PRINT statement at some point.
Sounds good.