[#105450] [Ruby master Feature#18228] Add a `timeout` option to `IO.copy_stream` — "byroot (Jean Boussier)" <noreply@...>
SXNzdWUgIzE4MjI4IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGJ5cm9vdCAoSmVhbiBCb3Vzc2llciku
11 messages
2021/09/27
[ruby-core:105215] [Ruby master Feature#14579] Hash value omission
From:
"baweaver (Brandon Weaver)" <noreply@...>
Date:
2021-09-13 03:54:04 UTC
List:
ruby-core #105215
Issue #14579 has been updated by baweaver (Brandon Weaver).
knu (Akinori MUSHA) wrote in #note-18:
> We should allow it to call a (private) method if no variable with the name defined. We use methods in RSpec or with attr_reader that look like variables, and programmers don't necessarily distinguish between methods from variables when writing a program. I believe this syntax should take methods into account.
I would agree that (private) methods are very useful here, especially `attr_*` methods. There are a few cases I would wonder what they do:
* `@var:` - Would this work with instance/class/global/constant variables if they're valid symbols?
* `a = 1; {a:, b: 3}` - Does it support mixing omissions and regular values?
* `p a:, b: 3` - Does it work with implied hashes / keywords? (I think yes).
I agree that `{ "#{ str }": }` should not be allowed, as it presents potential for abuse and vulnerabilities.
I've [PR'd the second case on mixed values](https://github.com/ruby/ruby/pull/4829), but just considered the first with ivars and similar concepts. I'm not sure which way that should go.
----------------------------------------
Feature #14579: Hash value omission
https://bugs.ruby-lang.org/issues/14579#change-93622
* Author: shugo (Shugo Maeda)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
How about to allow value omission in Hash literals:
```ruby
x = 1
y = 2
h = {x:, y:}
p h #=> {:x=>1, :y=>2}
```
And in keyword arguments:
```ruby
def login(username: ENV["USER"], password:)
p(username:, password:)
end
login(password: "xxx") #=> {:username=>"shugo", :password=>"xxx"}
```
---Files--------------------------------
hash_value_omission.diff (619 Bytes)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>