Skip to content

Java updates#1

Open
pfarner wants to merge 4 commits into
evmorov:sourcefrom
pfarner:JavaUpdates
Open

Java updates#1
pfarner wants to merge 4 commits into
evmorov:sourcefrom
pfarner:JavaUpdates

Conversation

@pfarner

@pfarner pfarner commented Jun 15, 2016

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

Comment thread code/ArrayCount.java Outdated
if (n > 10)
count++;
System.out.println(count);
System.out.println(arr.stream().count());

Copy link
Copy Markdown
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
Copy Markdown
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

evmorov commented Jun 18, 2016

Copy link
Copy Markdown
Owner

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

sirex commented Jun 19, 2016

Copy link
Copy Markdown
Contributor

@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.

4 participants