agentsclimarketplace

Run2 scala option handling

Skill cxcscmu/SkillLearnBench/skills/b2-self-feedback-claude-opus-4-6/python-scala-translation/run2_scala-option-handling

Handling absence and nullability in Scala using Option, with patterns for translating Python None handling.From its SKILL.md

Install
npx -y skills add cxcscmu/SkillLearnBench --skill run2_scala-option-handling

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

SKILL.md

1.0 KB, 230 tokens by cl100k_base, as published. Nobody here has run it

Option Handling in Scala

Python None -> Scala Option

  • x: str | None -> x: Option[String]
  • if x is None -> x match { case None => ... case Some(v) => ... }
  • Or use .map, .flatMap, .getOrElse, .fold

Processing Pipelines with Option

Instead of mutable var + early returns:

// BAD (Python-like)
var w = word
if (condition) w = transform(w)
if (w.length < min) return None

// GOOD (functional Scala)
Some(word)
  .map(w => if (condition) transform(w) else w)
  .filter(_.length >= min)
  .map(w => maxLen.fold(w)(m => w.take(m)))
  .filter(_.nonEmpty)

Option with Collections

  • list.flatMap(f) where f returns Option naturally filters None
  • collectFirst for finding first matching element
  • iterator.map(...).collectFirst { case Some(x) => x } for lazy first-match

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.