I don't envy any person that would support such "one liners", but here's the Python version:
python3 -c 'from pathlib import Path; from collections import Counter; from os.path import splitext,dirname; c=Counter(); c.update(dirname(x)+" "+splitext(x)[1] for x in Path(".").glob("**/*")); import pprint; pprint.pprint(c)'
which one is easier to read, what do you think?
Your claim that you know Python "pretty well" seems dubious.
Good engineering is about writing a code which is reliable and easy to maintain. In my experience, Ruby's track record is abysmal on both counts.
P.S. Since I'm in the golfing mood, here's an one-liner in a statically typed language, which would be OBVIOUSLY not as elegant as the wonderful Ruby, right?
echo 'package main; import "os"; import "fmt"; import "path/filepath"; func main() { c := make(map[string]int); filepath.Walk(".", func(f string, _ os.FileInfo, _ error) error {c[filepath.Dir(f)+" "+filepath.Ext(f)]+=1; return nil}); for k,v := range c {fmt.Println(k, v)}}' > /tmp/a.go && go run /tmp/a.go
To talk about "easiness to read", you should learn more about functional programming and Ruby, of course. It's difficult for everyone to understand text or code if language it's written by is not known well.
I'm impressed that you reach an insight that not all prog.languages looks the same good in different applications.
So you still need only couple of steps to reach things that I talk about in beginning. And everyday exercises is very good habits. So You are definitely on the right way. Good job!
But your way to discuss here is boring me. I don't see any point to continue talk in this style. Good luck!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I don't envy any person that would support such "one liners", but here's the Python version:
which one is easier to read, what do you think?
Your claim that you know Python "pretty well" seems dubious.
Good engineering is about writing a code which is reliable and easy to maintain. In my experience, Ruby's track record is abysmal on both counts.
P.S. Since I'm in the golfing mood, here's an one-liner in a statically typed language, which would be OBVIOUSLY not as elegant as the wonderful Ruby, right?
To talk about "easiness to read", you should learn more about functional programming and Ruby, of course. It's difficult for everyone to understand text or code if language it's written by is not known well.
I'm impressed that you reach an insight that not all prog.languages looks the same good in different applications.
So you still need only couple of steps to reach things that I talk about in beginning. And everyday exercises is very good habits. So You are definitely on the right way. Good job!
But your way to discuss here is boring me. I don't see any point to continue talk in this style. Good luck!