Skip to content

Instantly share code, notes, and snippets.

@taku0
Created January 21, 2015 14:07
Show Gist options
  • Select an option

  • Save taku0/1fcf50214a71593a72fa to your computer and use it in GitHub Desktop.

Select an option

Save taku0/1fcf50214a71593a72fa to your computer and use it in GitHub Desktop.
Informal swift indentation tests
1 +
2 + 5 *
3
1 +
2 + 5
+ 3
let foo: Foo<A> =
bar
func foo() {
bar
.buz()
bar
.buz()
}
func foo() {
timer = NSTimer.scheduledTimerWithTimeInterval(
1.0,
target: self,
selector: Selector("onTimer"),
userInfo: nil,
repeats: true)
}
func foo() {
let x = bar
.buz() ??
defaultValue
}
public func tableView(tableView: UITableView,
commitEditingStyle editingStyle:
UITableViewCellEditingStyle,
forRowAtIndexPath indexPath: NSIndexPath) {
}
public func tableView(
tableView: UITableView,
commitEditingStyle editingStyle: UITableViewCellEditingStyle,
forRowAtIndexPath indexPath: NSIndexPath) {
}
func foo() {
if foo {
A
.b()
}
}
class Foo<A: B<C>>:
Bar
switch {
case foo:
foo
foo
foo
case
foo, bar, buz:
foo
foo
default:
foo
foo
}
switch true {
case foo where bar,
bar where baz:
}
enum Foo: Bar {
case foo
case bar
var foo
}
let x = 1 +
1
let x: Foo? =
a
foo?[bar] +
a
func a () {
a
}
func a ()
{
a
}
@IBAction public func f() {
a
}
public func f()
{
a
}
[a
, b
, c]
[a,
b,
c]
[a
, b
, c
]
[a,
b,
c
]
[
a
, b
, c]
[
a,
b,
c]
[
a
, b
, c
]
[
a,
b,
c
]
public class Foo: A,
B,
C {
a
}
class Foo: A
, B
, C {
a
}
class Foo: A
, B
, C {
a
}
@objc
class Foo:
A,
B,
C {
a
}
class Foo:
A
, B
, C {
a
}
class Foo
: A {
}
func foo(a: A) -> B {
a
}
class Foo<A,
B,
C> {
a
}
class Foo<A> : Foo, Bar,
Baz {
a
}
let foo = bar +
baz +
a
let foo =
bar +
baz +
a
a +
a +
a
let foo = bar
+ baz
+ a
a
+ a
+ a
let foo = [
bar:
baz,
bar:
baz,
bar
:baz,
bar
:baz,
]
let foo = [
bar
]
let foo = {
a
}
for var index = 0; index < 3; ++index {
foo
}
func Foo(b: Double...) -> Bool {
foo
}
let json_ary = NSJSONSerialization
.JSONObjectWithData(data, options: nil, error: &json_err) as NSArray
typealias Foo = Bar<Foo.Baz, Foo>
let foo = bar <
baz
class Foo {
foo;
foo;
{
}
let a =
1
let a
= 1
111 + 111
+ 2
+ 3
let a = a.
b
let a = a
.b
class a:
A,
B?,
C,
D,
E!,
F,
GG,
H<A<B>>,
I {
a
}
protocol Foo {
func foo() -> Foo<(A,
B),
[C,
D]>
func bar() -> Int
}
public func a() {
}
class func a() {
}
1
+ 1
class func a(a
: a = 1,
a
: a =
1,
a
: a
= 1,
aaa:
a,
a:
a) {
let x =
1
let x
= 1
x
+ x
x +
x
x
- x
x -
x
x
* x
x *
x
1 +
(1)
(a
* 1
* 1
* 1)
(
a
* 1
* 1
* 1
)
({
a
})
UIView.animateWithDuration(1.0,
animations: {
foo.center =
CGPoint(x:
x
+ 1,
y:
y +
1)
foo.center
= CGPoint(x: 0, y: 0)
}
) {
completed in
foo(bar)
}
a.foo(
a
)
foo(
a
)
UIView.animateWithDuration(
1.0,
animations: {
foo.center =
CGPoint(x:
x
+ 1,
y:
y +
1)
foo.center
= CGPoint(x: 0, y: 0)
}
) {
completed in
foo(bar)
}
(a *
1 *
1 *
1)
let a
= a
? a
+ 1
: a
+ 1
let a =
a
? a
+ 1
: a
+ 1
let a = a
? a
+ 1
: a
+ 1
a
? a
+ 1
: a
+ 1
a
?
a
+ 1
:
a
+ 1
aaaaa ? (
a
+ 1
) : (
a
+ 1
)
foo + (
a
) + (
a
)
foo(
bar
)
[a
* a,
a
* a,
]
{
a
* a
a
* a
}
{a
* a
a
* a
}
(a
: a = 1,
a
: a,
aaa:
a,
a:
a)
if a {
a
} else if b {
a
} else if a {
a
} else {
a
}
if (a
.b) {
c
}
[ 1
, 2
, 3
]
}
public func a(a:
a,
aaa:
aaa) {
a
}
class func a(
a: a,
a: a,
a: a) {
a
a(
a,
a,
a,
)
a(a,
a,
a)
}
func a(a,
a: [
(A,
B)
]
a: a) {
a
}
func a() -> a {
a
}
func a()
-> a {
a
}
func a() ->
a {
a
}
func a() -> a
{
a
}
func a()
-> a
{
a
}
func a() ->
a
{
a
}
func a() ->
a<Foo> {
a
}
func a() ->
(a, a) {
a
}
func a() ->
[a] {
a
}
foo?
(bar)
foo?
[bar]
foo
?? bar
foo ??
bar
foo ??
{
a
}
foo ?? {
a
}
foo as?
bar
foo as
bar
foo is
bar
foo
as? bar
foo
as bar
foo
is bar
}
func foo() {
a
.b
let x = [
[
a
]
]
}
protocol Foo {
func foo()
func foo()
func foo()
}
a
.a
a {
}
{
a
a
a
a
a
}
a +
a +
a +
a
a;
a;
a;
a;
{
a;
a;
a;
}
a {
}
b (
)
[
]
abc (
def
)
abc(def
ggg)
;
""
a +
a
+ a
{
a,
a,
a,
}
{
a
b
}
a a a {
a
}
func () {
foo {
a
}
foo ?
aas : a
foo ?
+ aas : a
let x =
a
let x =
+ a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment