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?
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 https://blog.mozilla.org/nfroyd/2019/04/25/an-unexpected-ben...).
1) Use clang to build on Windows.
2) Use the subset of C99 which is implemented in Visual Studio (which also requires compiling as C++, which isn't that difficult to handle).
Compared to the rest, C99 contains a lot of useful improvements.
Oof. Call me old fashioned, but I liked the consistency of not being able to call private methods with an explicit receiver. Oh well!
The rest of this looks great, thanks Ruby team!
Sidenote: I can't think of a use case where this is a good idea.
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 shouldn't typically need to be using `self` at all, except when it's clarifying or disambiguating, so you shouldn't generally run into that issue. On occasion, though, you add a `self.` prefix to a method call and can break code that was otherwise working, because you've subjected your code to a scope protection that it wasn't subject to before.Will have to properly try it out.
I wonder what's going to be the idiomatic way to handle a failed match. Elixir ends the process but there is likely a supervisor to restart it. In the case of Ruby the process ends and there is nothing to restart it. In the case of Rails I expect the web request to fail with a 500 and maybe the next one will get more luck.
Yes in other languages, but as far as I am aware that is not the case in Ruby ( Specific to Rails ) . At least I wouldn't use so huge to describe the improvement.
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!Coming from Perl, map() there can return fewer elements than the source list, so pattern matching works already. A short skim of Ruby's map seems to imply it always returns something with the same number of elements.
Edit: I was confused about what this feature did. So this subthread is still interesting, but mostly unrelated.
Further, the pattern matching feature is significantly different than `map` imo.