Skip to content

Instantly share code, notes, and snippets.

@slavapestov
slavapestov / foo.swift
Created December 17, 2015 00:53
Array of functions
func foo() {
// Doesn't parse correctly
// let a = [() -> ()]()
let b = [(Int, Int)]()
let a: [() -> ()] = []
}
func foo<T>(_: T) {
print("Self = \(T.self)")
}
protocol P {
func requirement()
}
extension P {

Keybase proof

I hereby claim:

  • I am slavapestov on github.
  • I am spestov (https://keybase.io/spestov) on keybase.
  • I have a public key ASDtaF_IPmUGQ8saUB0otbOZbh8Y57SqiiSuq23Vlugttwo

To claim this, I am signing this object:

// Example 1
protocol P {
func f() -> Self
}
extension P {
func f() -> Self {
return self
}
}
struct S {
let x: Int
init(x: Int) { self.x = x }
// This is allowed
init(x2: Int) {
self.init(x: x2)
}
struct AnyEncodable : Encodable {
var wrapped: Encodable
func encode(to encoder: Encoder) throws {
try wrapped.encode(to: encoder)
}
}
Equivalence classes:
* Equivalence class represented by τ_0_0:
Members: τ_0_0
Conformances:Collection, Sequence
Same-type constraints:
---Rewrite tree---
`--(cont'd)
`--Collection.SubSequence
`--Collection.Index --> [Collection.Indices -> Sequence.Element]
protocol P
where A.C == C.A,
A.D == D.A,
B.C == C.B,
B.D == D.B,
C.E == E.C.A,
D.E == E.D.B,
C.C.A == C.C.A.E {
associatedtype A : P
associatedtype B : P
#include <stdio.h>
#include <termios.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/termios.h>
#include <sys/types.h>
int main() {
int fd;
noby# diff -c3 keyboard.ps.orig keyboard.ps
*** keyboard.ps.orig Mon Jul 27 08:55:38 1992
--- keyboard.ps Mon Jul 27 09:17:11 1992
***************
*** 45,50 ****
--- 45,51 ----
/KB_SUN4_US101A 23 def
/KB_SUN4_JAPAN 36 def
/KB_SUN5_US 37 def
+ /KB_SUN5_US_COMPACT 84 def