Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save twolfe18/f639ed6d3b5dccf73558 to your computer and use it in GitHub Desktop.
Save twolfe18/f639ed6d3b5dccf73558 to your computer and use it in GitHub Desktop.
File f = new File("foo.txt");
// You're not allowed to make a Path using raw strings,
// that would be dangerous!
Path p = FileSystems.getDefault().getPath("foo.txt");
// Both of these type check :)
f.getName().endsWith(".txt"); // true
p.getFileName().endsWith(".txt"); // false
@twolfe18
Copy link
Author

Path should not have the method boolean endsWith(String)

@twolfe18
Copy link
Author

Also, though this is one example and the sentiment is general, try stepping through various java.util.Stream methods trying to find a bug sometime. I don't know why they tried to go so functional, including things like File.isDirectory is a method while Files.isDirectory is a function. Should have added java.util.function.*, closures, and stopped there. If I wanted to write functional programs, I wouldn't be using Java!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment