diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 24e8ec6..99f18fc 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -390,9 +390,7 @@ In python we might see:: >>> optional_arg(keyword1=1, pos2=2, pos1=3, keyword2=4) [3, 2, 1, 4] -The same thing in Hy: - -.. code-block:: clj +The same thing in Hy:: => (defn optional_arg [pos1 pos2 &optional keyword1 [keyword2 88]] ... [pos1 pos2 keyword1 keyword2]) @@ -410,6 +408,17 @@ The same thing in Hy: See how we use kwapply to handle the fancy pssing? :) +There's also a dictionary-style keyword arguments construction that +looks like:: + +.. code-block:: clj + + (defn another_style [&key {"key1" "val1" "key2" "val2"}] + [key1 key2]) + +The difference here is that since it's a dictionary, you can't rely on +any specific ordering to the arguments. + Hy also supports **args and **kwargs. In Python:: def some_func(foo, bar, *args, **kwargs):