# .Q.def\[\]

**URL:** <https://forum.kx.com/t/q-def/13900>\
**Category:** Academy Support\
**Tags:** imported\
**Created:** [April 30, 2024, 6:17pm UTC](https://forum.kx.com/t/q-def/13900 "2024-04-30T18:17:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [April 30, 2024, 6:17pm UTC](https://forum.kx.com/t/q-def/13900/1 "2024-04-30T18:17:05Z")

</div>

[https://learninghub.kx.com/forums/topic/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.

---

<div class="post-metadata">

**Author:** ![rocuinneagain](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/rocuinneagain/32/287_2.png) [@rocuinneagain](https://forum.kx.com/u/rocuinneagain)\
**Post date:** [April 30, 2024, 7:03pm UTC](https://forum.kx.com/t/q-def/13900/2 "2024-04-30T19:03:26Z")

</div>

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

- [https://code.kx.com/q/ref/enlist/](https://code.kx.com/q/ref/enlist/)
- [https://code.kx.com/q/basics/dictsandtables/#construction](https://code.kx.com/q/basics/dictsandtables/#construction)

```
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

- [https://code.kx.com/q//releases/ChangesIn4.1/#dictionary-literal-syntax](https://code.kx.com/q//releases/ChangesIn4.1/#dictionary-literal-syntax)

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

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [May 7, 2024, 11:28am UTC](https://forum.kx.com/t/q-def/13900/3 "2024-05-07T11:28:49Z")

</div>

thanks.

---

<div class="post-metadata">

**Author:** ![lestat-jin](https://sea2.discourse-cdn.com/flex002/user_avatar/forum.kx.com/lestat-jin/32/128_2.png) [@lestat-jin](https://forum.kx.com/u/lestat-jin)\
**Post date:** [May 7, 2024, 11:29am UTC](https://forum.kx.com/t/q-def/13900/4 "2024-05-07T11:29:24Z")

</div>

thanks!
