Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java updates #1

Open
wants to merge 4 commits into
base: source
Choose a base branch
from
Open

Java updates #1

wants to merge 4 commits into from

Conversation

pfarner
Copy link

@pfarner pfarner commented Jun 15, 2016

  • removed redundant generic type specifications
  • favored try-with-resources
  • applied streams where that seemed appropriate and the other languages used that style

if (n > 10)
count++;
System.out.println(count);
System.out.println(arr.stream().count());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not just count, but filtered count. You should count only those values greater than 10. In Python this looks something like this:

sum(1 for i in arr if i > 10)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I missed that. Some unit tests might've caught it.

@evmorov
Copy link
Owner

evmorov commented Jun 18, 2016

Thank you! I'm thinking about how to manage language versions. I want to keep Java 7 examples. As soon as I decide this I'll merge this PR.

@sirex
Copy link
Contributor

sirex commented Jun 19, 2016

@evmorov I had same thought, some languages, for example JavaScript drastically differs between versions.

I think, language mapping based on file extension should be change on path.

This:

CODE_EXTENSION = {
    'coffee' => 'coffeescript',
    'rb' => 'ruby',
    'java' => 'java',
    'py' => 'python',
    'php' => 'php'
}.freeze

can be changed to this:

CODE_EXTENSION = {
    'coffee' => 'coffeescript',
    'ruby' => 'ruby',
    'java/7' => 'java',
    'python/3' => 'python',
    'php' => 'php'
}.freeze

And files can be organized in to directories, for example:

`-- code/
    |-- coffee/
    |   `-- array_add.py
    |-- ruby/
    |   `-- array_add.py
    |-- java/
    |   `--7/
    |      `-- ArrayAdd.py
    |-- php/
    |   `-- ArrayAdd.py
    `-- python/
        `-- 3/
            `-- array_add.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants