summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzverok <zverok.offline@gmail.com>2023-02-15 22:42:22 +0200
committerVictor Shepelev <zverok.offline@gmail.com>2023-02-19 22:32:52 +0200
commitce0f3de032ea0dffbfd20dfbfe33453f65ec5a7c (patch)
treeb58946be2c6aa684b44105e1c5bad8a6e3617cbf
parent4f049e915d08697ee9fea5d2c885285d309a7654 (diff)
[DOC] Update pattern matching docs for 3.2
* Remove section about experimental status * Add references to core objects that can deconstruct
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7316
-rw-r--r--doc/syntax/pattern_matching.rdoc28
1 files changed, 5 insertions, 23 deletions
diff --git a/doc/syntax/pattern_matching.rdoc b/doc/syntax/pattern_matching.rdoc
index b7d614770c..e49c09a1f8 100644
--- a/doc/syntax/pattern_matching.rdoc
+++ b/doc/syntax/pattern_matching.rdoc
@@ -415,6 +415,11 @@ Additionally, when matching custom classes, the expected class can be specified
end
#=> "matched: 1"
+These core and library classes implement deconstruction:
+
+* MatchData#deconstruct and MatchData#deconstruct_keys;
+* Time#deconstruct_keys, Date#deconstruct_keys, DateTime#deconstruct_keys.
+
== Guard clauses
+if+ can be used to attach an additional condition (guard clause) when the pattern matches. This condition may use bound variables:
@@ -445,29 +450,6 @@ Additionally, when matching custom classes, the expected class can be specified
end
#=> "matched"
-== Current feature status
-
-As of Ruby 3.1, find patterns are considered _experimental_: its syntax can change in the future. Every time you use these features in code, a warning will be printed:
-
- [0] => [*, 0, *]
- # warning: Find pattern is experimental, and the behavior may change in future versions of Ruby!
- # warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!
-
-To suppress this warning, one may use the Warning::[]= method:
-
- Warning[:experimental] = false
- eval('[0] => [*, 0, *]')
- # ...no warning printed...
-
-Note that pattern-matching warnings are raised at compile time, so this will not suppress the warning:
-
- Warning[:experimental] = false # At the time this line is evaluated, the parsing happened and warning emitted
- [0] => [*, 0, *]
-
-So, only subsequently loaded files or `eval`-ed code is affected by switching the flag.
-
-Alternatively, the command line option <code>-W:no-experimental</code> can be used to turn off "experimental" feature warnings.
-
== Appendix A. Pattern syntax
Approximate syntax is: