Can anyone point me to an online Java compiler which runs the JDK on Windows? I only find Linux systems.

I would be particularly interested in what

java.nio.file.Path.of("a/b/c")

returns on a Windows system. My hunch is that it is the same as

java.nio.file.Path.of("a\\b\\c")

because the forward slash, afair, also works as a path separator. Or is the forward slash merely a no-go character like ':' and many others?

#java #windows #filepath #filename

XCTest pro tip: if you create your own assert functions, add file: and line: parameters to see where the error „really" happened. Example from my UITableView assertion DSL:

@discardableResult
func assertNumberOfSections(_ number: Int, file: StaticString = #filePath, line: UInt = #line) -> Self {
XCTAssertEqual(
tableView.numberOfSections,
number,
file: file, line: line
)
return self
}

@nicklockwood The old assertions take

file: StaticString = #filePath, line: UInt = #line

The new ones are slightly different (String and Int), plus the extra fileID & column

@alilly #filePath preserves the entire original path. if you want to make sure that your debug messages include full paths, use that.

  • /Volumes/Mercury (Roman God)/Projects/ALMDeityManager/Sources/ALMDeityManager/Deities.swift
  • /Volumes/Mercury (planet)/Projects/AstronomyPal/RelativisticOrbitalCorrections.swift
  • /Volumes/Mercury (Freddie)/Projects/InvisibleMan/SeeRightThroughMe.swift

@polpielladev
Yeah, thats what I meant. As I have very simple Packages and the only difference between them is the name, I now use this trick to dynamically generate the name of the package from its foldername:

let name = String(#filePath.split(separator: "/").reversed()[1])

This way, all the package.swift files are identical.

TIL that how GitHub figures out syntax highlighting for Swift files is one huge plist file of 5000 lines maintained by TextMate and pulled in as a submodule into linguist. Hopefully this PR should also add proper syntax highlighting for `#filePath`: https://github.com/textmate/swift.tmbundle/pull/42
Add #filePath to variables list by BalestraPatrick · Pull Request #42 · textmate/swift.tmbundle

This PR adds the new #filePath variable that was added in Swift 5.3. I noticed that GitHub doesn't syntax highlight it at all right now, so hopefully this should fix it. Swift evolution proposa...