Skip to content

Instantly share code, notes, and snippets.

View j-j-m's full-sized avatar
🔮
Pondering my orb

Jacob Martin j-j-m

🔮
Pondering my orb
View GitHub Profile
@j-j-m
j-j-m / dynamic_member_lookup_environment.swift
Created December 23, 2018 23:59 — forked from DougGregor/dynamic_member_lookup_environment.swift
Using Swift 4.2's @dynamicMemberLookup to expose environment variables
import Darwin
@dynamicMemberLookup
struct Environment {
subscript(dynamicMember name: String) -> String? {
get {
guard let value = getenv(name) else { return nil }
return String(validatingUTF8: value)
}