Skip to content

Instantly share code, notes, and snippets.

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 {
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);
}
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
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; }
print("Hello Swift!")
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;
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
}
// Swift 2.2
import XCTest
import Foundation
import RealmSwift
private let n = 100000
private let numberOfLoops = 1000
class RealmPerformanceTest: XCTestCase {
func testIndexedFilterPerformance() {
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.
# coding:utf-8
import tensorflow as tf
from random import choice
zun = -1.0
doko = 1.0
zun_length = 4
zundoko_length = zun_length + 1