Skip to content

struct — examples

← all topics · 202 examples · page 5 of 5 · raw source ↓

Compiles

// E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript).
// provenance: TypeInfoTests.cs::MemberSynthesizer_AddedMethod_CompilesAndRuns   topic: struct   status: unverified
// compiles cleanly (no auto-run claim was extracted)

namespace Test
struct Box { v: int }
func go() -> int {
    let b = Box { v: 7 }
    return b.answer()
}

Runs `Test` → 42

// E# — a verified example from the E# language corpus (CLR language; .es, not ECMAScript).
// provenance: TypeInfoTests.cs::MemberSynthesizer_SatisfiesInterfaceConformance   topic: struct   status: unverified
// verified behavior: Test.Test(...) == 42

namespace Test
interface IAnswer { func answer() -> int }
struct Box : IAnswer { v: int }
func go() -> int {
    let b = Box { v: 1 }
    return b.answer()
}