this post was submitted on 24 Mar 2024
2 points (100.0% liked)

Programmer Humor

19817 readers
539 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] silasmariner@programming.dev 0 points 9 months ago* (last edited 9 months ago) (1 children)

They missed out the context code:

trait DoW { def length: FiniteDuration }
object Monday extends DoW { override def length = 24.hours }
...
implicit def toDoW(s: String): DoW = s match {
 case "Monday" => Monday
...
}
var day: DoW = _

(Duration formatting and language identification are left as an exercise for the reader)

[–] Magnetar@feddit.de 1 points 9 months ago (1 children)
[–] silasmariner@programming.dev 0 points 9 months ago (1 children)

Implicit was too much of a give away wasn't it?

[–] Magnetar@feddit.de 0 points 9 months ago* (last edited 9 months ago)

I've literally seen code that does something awfully similar. But you could have used an Enumeration.

Fuck, I think you just gave me an idea for an issue in my code that has bugged me for days.