mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Merge pull request #541 from sogaiu/match-doc-formatting
Tweak match docstring
This commit is contained in:
		| @@ -1575,16 +1575,26 @@ | |||||||
|  |  | ||||||
| (defmacro match | (defmacro match | ||||||
|   ``` |   ``` | ||||||
|   Pattern matching. Match an expression x against |   Pattern matching. Match an expression `x` against any number of cases. | ||||||
|   any number of cases. Each case is a pattern to match against, followed |   Each case is a pattern to match against, followed by an expression to | ||||||
|   by an expression to evaluate to if that case is matched. A pattern that is |   evaluate to if that case is matched.  Legal patterns are: | ||||||
|   a symbol will match anything, binding x's value to that symbol. An array |  | ||||||
|   will match only if all of it's elements match the corresponding elements in |   * symbol -- a pattern that is a symbol will match anything, binding `x`'s | ||||||
|   x. A table or struct will match if all values match with the corresponding |     value to that symbol. | ||||||
|   values in x. A tuple pattern will match if it's first element matches, and the following |  | ||||||
|   elements are treated as predicates and are true. The last special case is |   * array -- an array will match only if all of its elements match the | ||||||
|   the '_ symbol, which is a wildcard that will match any value without creating a binding. |     corresponding elements in `x`. | ||||||
|   Any other value pattern will only match if it is equal to x. |  | ||||||
|  |   * table or struct -- a table or struct will match if all values match with | ||||||
|  |     the corresponding values in `x`. | ||||||
|  |  | ||||||
|  |   * tuple -- a tuple pattern will match if its first element matches, and the | ||||||
|  |     following elements are treated as predicates and are true. | ||||||
|  |  | ||||||
|  |   * `_` symbol -- the last special case is the `_` symbol, which is a wildcard | ||||||
|  |     that will match any value without creating a binding. | ||||||
|  |  | ||||||
|  |   Any other value pattern will only match if it is equal to `x`. | ||||||
|   ``` |   ``` | ||||||
|   [x & cases] |   [x & cases] | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose