From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 00B1619C022B for ; Wed, 25 Nov 2015 21:29:19 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 511A1B5D8C3 for ; Wed, 25 Nov 2015 22:00:24 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 1CB2218CC7D0 for ; Wed, 25 Nov 2015 22:00:24 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 9594C1204E5; Wed, 25 Nov 2015 22:00:22 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 15F751204B3 for ; Wed, 25 Nov 2015 22:00:14 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=e72Tn/NM6XaP+cMZvQpRPuazulg=; b=nXHwtVU3P3QbUxbarB Mbu+baPnJBxlOALqrtr2m4UnlslitqkuTGNBVivxBagjFp+z9snC/TY/GFYCe4rP qEjQ4yoFrZCFv7TD2UMelkKFkLugsSxDxd2nFKKsW4hU+lizk1a9YTdoQr5N6iPn i2TsiiRfQZ8wPSJfF0ftET9UM= Received: by filter0807p1mdw1.sendgrid.net with SMTP id filter0807p1mdw1.22969.5655B0D54B 2015-11-25 13:00:05.706134941 +0000 UTC Received: from herokuapp.com (ec2-54-147-232-78.compute-1.amazonaws.com [54.147.232.78]) by ismtpd0006p1iad1.sendgrid.net (SG) with ESMTP id AyGk4jNfQB-Jxhj5V2WrQg Wed, 25 Nov 2015 13:00:05.994 +0000 (UTC) Date: Wed, 25 Nov 2015 13:00:05 +0000 From: hanmac@gmx.de To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46358 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11734 X-Redmine-Issue-Author: kaoss X-Redmine-Sender: Hanmac 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4VP1jW8nxvcjYG5g8Z+jjTl4xSd+zyPXTxIW E8WFAFHCh7UoHTxQDz0wtKA3K52N9Zwd4uZoTQ1IM9U/JQRpfEk2TIbAxf2sAghH8NsxBHDZuD3/jd L0LYK51YhWMxZ6JJRQJJDy7sgwqOCdCRlHqV X-ML-Name: ruby-core X-Mail-Count: 71683 Subject: [ruby-core:71683] [Ruby trunk - Feature #11734] Improved ternary operator 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11734 has been updated by Hans Mackowiak. Yurko Bregey wrote: > Hans Mackowiak wrote: > > why not: > > > > ```ruby > > (x = some_long_expression) ? x.to_s : 'foobar' > > ``` > > think it's not good. Ruby 2.2.3p173 shows warning: > > ~~~ > warning: found = in conditional, should be == > ~~~ you might did something wrong because on "ruby 2.3.0dev (2015-11-25 trunk 52749) [x86_64-linux]" it doesn't show any warning for me ---------------------------------------- Feature #11734: Improved ternary operator https://bugs.ruby-lang.org/issues/11734#change-55086 * Author: Yurko Bregey * Status: Open * Priority: Normal * Assignee: ---------------------------------------- In ternary operator it would be nice to be able to pass expression result from *condition* into *value_if_true/value_if_false* in such way: `some_long_expression ? &.to_s : 'foobar'` where `&` refers to `some_long_expression` Instead of doing: `some_long_expression ? some_long_expression.to_s : 'foobar'` or: `result = some_very_very_long_expression result ? result.to_s : 'foobar'` -- https://bugs.ruby-lang.org/