From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id B4C231F87F for ; Thu, 22 Nov 2018 22:29:17 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6DFF612198F; Fri, 23 Nov 2018 07:29:15 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id A4AAB1219EB for ; Fri, 23 Nov 2018 07:29:13 +0900 (JST) Received: by filter0033p3iad2.sendgrid.net with SMTP id filter0033p3iad2-13762-5BF72DB5-1C 2018-11-22 22:29:09.641942001 +0000 UTC m=+38468.032577767 Received: from herokuapp.com (ec2-54-161-159-209.compute-1.amazonaws.com [54.161.159.209]) by ismtpd0025p1iad2.sendgrid.net (SG) with ESMTP id OMhOosOOS-CqtbuDacg_1w for ; Thu, 22 Nov 2018 22:29:09.664 +0000 (UTC) Date: Thu, 22 Nov 2018 22:29:10 +0000 (UTC) From: matz@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 65385 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15231 X-Redmine-Issue-Author: mame X-Redmine-Sender: matz X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS50AbovLlDI7uTAk7LeWjWxlw+Tc9yRrk3NUr QMtE15h8Tg7H1vnACqm++g5vPZnBH7asScMVpD5gTgkcFfa1Bk5Vktm1e7TWbT21l2dHmZoA74OWRP q+F4qA1jgaZ4cbb+05MPxVKibk0y22k3AQkljtYt+BDflXaYyWcP9SktbQ== X-ML-Name: ruby-core X-Mail-Count: 89986 Subject: [ruby-core:89986] [Ruby trunk Feature#15231] Remove `Object#=~` X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15231 has been updated by matz (Yukihiro Matsumoto). I vote for the proposed change. Let's give deprecation warning first. I don't think we need to remove `!~` from `Kernel`. Matz. ---------------------------------------- Feature #15231: Remove `Object#=~` https://bugs.ruby-lang.org/issues/15231#change-75091 * Author: mame (Yusuke Endoh) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- `Object#=~` receives (and just discards) an argument, and always returns nil. What purpose is this method for? The following behavior that `Object#=~` caused was confusing to me. ```RUBY ["foo"] =~ /foo/ #=> nil ``` More precisely: the actual example that I encountered was to parse coverage data from output of coverage measurement tool by using `Open3.capture2`: ```RUBY out = Open3.capture2("gcov", ...) # BUG: `out, =` was intended if out =~ /lines\.*: *(\d+\.\d+)%/ ... end ``` Obviously, I forgot a comma to receive the return value of `Open3.capture2`. The method returns a two-element array, and `out =~` calls `Object#=~`, which hid the bug. (Worse, I took several tens of minutes to debug it because I first thought that this is a bug of regexp, and spent tweaking the regexp.) I guess `Object#=~` was intended for general pattern matching, but presently the role was taken over by `Object#===`. So. How about removing `Object#=~`? Concerns: * @usa said `NilClass#=~` should be newly introduced because of: `if gets =~ /re/` * `Object#!~` is difficult to remove: some classes define only `#=~`, and expect `Object#!~` to delegate to `#=~`. -- https://bugs.ruby-lang.org/