I'm most excited for Enumerable#tally for counting occurrences of elements. From the example in the release: ["a", "b", "c", "b"].tally #=> {"a"=>1, "b"=>2, "c"=>1} There's more about this change here ( https://medium.com/@baweaver/ruby-2-7-enumerable-tally-a706a... ). I probably do this a few times a week: list.each_with_object(Hash.new(0)) { |v, h| h[v.something] += 1 }
For Python developers: this exists as collections.Counter.
Ruby 2.7
61–68 of 68 posts
Re: Ruby 2.7
#62Earlier quoted context omitted.
You've been able to use `send` to pierce the protected/private restriction forever, so this doesn't particularly change the nature of Ruby's method visibility rules. Now you can just use `self.foo` and it's the same as `self.send :foo`. class Foo def test priv # works self.send(:priv) # works self.priv # doesn't work under ruby 2.6- Foo.new.priv # doesn't work end private def priv puts "ran private" end end You shoul…
> You've been able to use `send` to pierce the protected/private restriction forever, so this doesn't particularly change the nature of Ruby's method visibility rules. I wasn't aware, thanks for pointing that out.
Re: Ruby 2.7
#63Earlier quoted context omitted.
Yeah I suppose my bigger beef is I just don't like dynamic languages. Perhaps it is in fact a good idea for them, but being someone primarily interested in types, it largely falls into the realm of "don't care."
Huh? Both Maybe / Optional and pattern matching is used in Haskell, Scala, and other typed languages... It's not about dynamic languages...
Re: Ruby 2.7
#64Earlier quoted context omitted.
3) Use C++17 with minimal features. This gives you a lot of needed libraries built-in and it is better supported than C99 (due to Windows).
> Use C++17 with minimal features To paraphrase JWZ, "now you have N+M problems"
Re: Ruby 2.7
#65I'm most excited for Enumerable#tally for counting occurrences of elements. From the example in the release: ["a", "b", "c", "b"].tally #=> {"a"=>1, "b"=>2, "c"=>1} There's more about this change here ( https://medium.com/@baweaver/ruby-2-7-enumerable-tally-a706a... ). I probably do this a few times a week: list.each_with_object(Hash.new(0)) { |v, h| h[v.something] += 1 }
list.group_by(&:itself).transform_values(&:count)
...but I'll be very happy to replace that with #tally!Re: Ruby 2.7
#66Earlier quoted context omitted.
Maybe I’ve just been bitten by the functional bug but I find they can communicate intent much better than scattering around null checks or catching exceptions (many of which require reading the source to understand what exceptions you might get). It’s great in large scale projects, which I think is where a dynamic language starts to show its warts.
An alternative to scattering null checks around or using exceptions for control flow could be more thoughtfully designing your data/object model. No additional language constructs required!
Re: Ruby 2.7
#67One of the interesting news is that they are now going to start requiring a C99 compiler, instead of only C90. I've been considering to do the same on my own projects. What does HN have to say about this? Is anyone here still working in a context where C99 is not an option? Did anyone else also recently switch to C99? How did it go?
It's now 2019, and as far as I know, MSVC still doesn't have full support for the 20-year-old C99 standard. So either you restrict yourself to the subset of C99 which MSVC understands (AFAIK, newer MSVC releases understand more and more of the C99 standard), or just decide MSVC is no longer relevant (which is easier now that clang-cl exists; some big projects like Firefox and Chrome went this way, see for instance ht…
Re: Ruby 2.7
#68Earlier quoted context omitted.
Why? Not being facetious. Wondering about the weights of benefits versus costs for users.
Mostly portable implementations of extensions for me; __thread, bool, inttypes.h, variadic macros, flexible array members etc. But declaring variables closer to the point of use is nice, as is struct initializers, compound literals and single line comments. Compared to the rest, C99 contains a lot of useful improvements.