Skip to content

Instantly share code, notes, and snippets.

print("Hello, WWDC!")
Hello love at first swipe.
Hello other side of the road.
Hello yogi on my wrist.
Hello driver, fast as you can.
Hello workout in my living room.
Hello every pitch, every highlight.
Hello self-combusting selfies.
Hello double tap heart.
Hello rain in five minutes.
// Swift 2.2
import XCTest
import Foundation
import RealmSwift
private let n = 100000
private let numberOfLoops = 1000
class RealmPerformanceTest: XCTestCase {
func testIndexedFilterPerformance() {
extension Dictionary {
func filterMap<T>(_ transform: (Value) -> T?) -> [Key: T] {
var transformed = [Key:T]()
for entry in self {
if let newValue = transform(entry.value) {
transformed[entry.key] = newValue
}
}
return transformed
}
import java.util.*;
import java.io.PrintStream;
public class CollectionsPerformance {
public static void main(String[] args) {
final PrintStream out = System.out;
final int n = 100000;
final Integer x = 42;
print("Hello Swift!")
import java.util.Arrays;
import java.util.List;
interface Integer {
int getValue();
}
final class ConcreteInteger implements Integer {
private final int value;
ConcreteInteger(int value) { this.value = value; }
func foo() -> Int { return 2 }
func foo() -> Float { return 3.0 }
let a: Int = foo()
let b: Float = foo()
print(a) // 2
print(b) // 3.0
public class GenericReturnType {
public static void main(String[] args) {
// 引数の型は `Object` なので戻り値から型パラメータが推論される
Integer n = id(42);
String s = id("xyz");
System.out.println(n);
System.out.println(s);
}

throws : async = try : await = catch : wait = rethrows : reasync = Result<T> : Promise<T>

throws : async = try : await

// Asynchronous selection by an action sheet
func actionSheet(itemes: [String]) async -> Int { ... }

// `await` must be in an `async` function
func foo() async {
@koher
koher / README.md
Last active February 26, 2017 14:39
SwiftScript Translation Catalog

SwiftScript Translation Catalog (Draft)

This is a catalog of translations by SwiftScript, a transpiler from Swift to JavaScript, for a hackathon. It supports only a subset of Swift and has some incompatibilities.

Supporting Library

SwiftScript tries to translate Swift codes to JS codes using builtin JS APIs. However some needs a supporting library to simulate behaviors of Swift. A typical example is ?..

If