.Q.def[]

https://learninghub.kx.com/forums/topic/q-def

trying to provide default parameters with the below statement:

d:.Q.def[`num1!5].Q.opt .z.x;


error as follows:


evaluation error:

type

[1] (.Q.def)

[0] d:.Q.def[`num1!5].Q.opt .z.x;
^


does .Q.def only takes in list or atoms such as the above is fine? Thanks.

Dictionaries require lists to be passed to either side of !. You can use enlist to make lists from atoms:

q)d:.Q.def[enlist[`num1]!enlist 5].Q.opt .z.x
q)d
num1| 5


If you are using kdb 4.1 you can use the new dictionary syntax which does not need enlist

q)d:.Q.def[([num1:5])].Q.opt .z.x
q)d
num1| 5

thanks.

thanks!