Skip to content

Working with strings/path is awkward #53

Description

@sagikazarmark

Given let filename: String! = "file.ext", filename.split(".")[0] returns String, not String! which is understandable.

But I can't find a good way to construct a path from this:

let dirname = filename.split(".")[0]

Failing cases

let name: String! = "/work/" + dirname
# Doesn't turn dirname into String!
assert { dirname != null }

let name: String! = "/work/" + dirname

The best solution I found so far:

# Make sure it's actually non-nil
assert { dirname != null }

let name = ["/work", filename.split(".")[0]].join("/")

I might be missing something, but I couldn't find a better solution so far.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions