close
Skip to content

feat(stdlib): Add Path.updateExtension#2282

Merged
ospencer merged 1 commit into
grain-lang:mainfrom
spotandjake:spotandjake-path-updateExtension
Apr 23, 2025
Merged

feat(stdlib): Add Path.updateExtension#2282
ospencer merged 1 commit into
grain-lang:mainfrom
spotandjake:spotandjake-path-updateExtension

Conversation

@spotandjake
Copy link
Copy Markdown
Member

This adds Path.updateExtension so users can set the current extension.

Edge Cases:

  • Regular, we just chop the extension and then append .<ext> to the end
  • Directory, we don't set the extension
  • Empty extension sets something like file.ext to file., this seems weird but I think it's the best option if a user actually wants to clear the extension they should use removeExtension.

Note: One thing I noticed is our examples for Path omit the Path. which means unless you do use Path.* (which I don't think we encourage) the examples are not runnable off the bat, I think we should fix this in a seperate pr for consistency across the stdlib.

This adds `Path.updateExtension` so users can set the current extension.

Edge Cases:
* Regular, we just chop the extension and then append `.<ext>` to the end
* Directory, we don't set the extension
* Empty extension sets something like `file.ext` to `file.`, this seems weird but I think it's the best option if a user actually wants to clear the extension they should use `removeExtension`.

Note: One thing I noticed is our examples for `Path` omit the `Path.` which means unless you do` use Path.*` (which I don't think we encourage) the examples are not runnable off the bat, I think we should fix this in a seperate pr for consistency across the stdlib.
@ospencer
Copy link
Copy Markdown
Member

It'd be cool if @alex-snezhko could take a look at this.

@ospencer ospencer added this pull request to the merge queue Apr 23, 2025
Merged via the queue into grain-lang:main with commit 6d795d0 Apr 23, 2025
12 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants