RSSAmplifier

nickb.dev · May 13, 2024

Dot or Not? A type safety story about file extensions

0
Sign in to vote or save

This site does not allow itself to be embedded. You can still read it on the original site — the toolbar below keeps your place in the directory.

Let’s write a function that takes in a file extension and returns a file type: 
 function fileType ( fileExtension : string ) {
 switch ( fileExtension ) {
 case '.mp4' : return 'video' ;
 // ...
 }
 }
 Our function assumes the file extension has a leading dot, but should it? 
 
 The Python standard library includes the dot in file extensions . 
 Rust…

Read on nickb.dev

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.