From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.1 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 5E08D1F453 for ; Wed, 17 Oct 2018 08:46:57 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BF005121A5C; Wed, 17 Oct 2018 17:46:55 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 68581121A02 for ; Wed, 17 Oct 2018 17:46:54 +0900 (JST) Received: by filter0090p3las1.sendgrid.net with SMTP id filter0090p3las1-17305-5BC6F6FB-1B 2018-10-17 08:46:51.68717301 +0000 UTC m=+445381.865473384 Received: from herokuapp.com (ec2-54-225-54-31.compute-1.amazonaws.com [54.225.54.31]) by ismtpd0025p1iad2.sendgrid.net (SG) with ESMTP id 17rq0-hbTfa0-mlUensR5w for ; Wed, 17 Oct 2018 08:46:51.385 +0000 (UTC) Date: Wed, 17 Oct 2018 08:46:52 +0000 (UTC) From: mame@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 64823 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15231 X-Redmine-Issue-Author: mame X-Redmine-Sender: mame 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4Rp1YsF7UzYZaHXL2re4HDXgU+s/TctXDL+a Sy7AmcTn7WvWl2KudtF7+tWDupOFc7hQPXt/UjiKdHrR7SfOoNFyNdQsyv3TKX0hPTxPGti4qpbMmX pgbaJeizKJv33onGUOFCY51Zr3S6WgkdtZYIAH9shYyrebbGSofdSPAoCQ== X-ML-Name: ruby-core X-Mail-Count: 89438 Subject: [ruby-core:89438] [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 reported by mame (Yusuke Endoh). ---------------------------------------- Feature #15231: Remove `Object#=~` https://bugs.ruby-lang.org/issues/15231 * 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. ``` ["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`: ``` 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 hided 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/