Suppose that Either is declared in the following way,
enum Either<T, U> {
case Left(T)
case Right(U)
}| package org.koherent.appengine.test; | |
| import java.io.IOException; | |
| import java.io.PrintWriter; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.Set; | |
| import java.util.TreeSet; | |
| import javax.servlet.ServletException; |
| protocol O { | |
| func f() -> String | |
| } | |
| struct A : O { | |
| func f() -> String { | |
| return "a" | |
| } | |
| } |
| struct Array2<T> { | |
| var buffer: Buffer<T> | |
| var count: Int | |
| init() { | |
| buffer = Buffer() | |
| count = 0 | |
| } | |
| init(_ elements: T...) { |
| import java.util.ArrayList; | |
| import java.util.Arrays; | |
| import java.util.List; | |
| import static java.lang.System.out; | |
| public class VarianceTest { | |
| static class Animal { | |
| } |
| a.map { b in | |
| b.map { c in { | |
| foo(b, c) | |
| } | |
| } | |
| for b in a { | |
| for c in b { | |
| foo(b, c) | |
| } |
| import java.util.*; | |
| Map<String, Integer> map = new TreeMap(); | |
| map.put("abc", 123); | |
| map.put("def", 456); | |
| map.put("ghi", 789); | |
| map.get("abc"); | |
| map.get(123); // java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer |
That was my misunderstanding especially about subtyping of value types.
I think it would be great if throws -> Foo were a syntactic sugar of -> Result<Foo>. Without affecting existing codes, it makes it possible to go back and forth between Manual Propagation and Automatic Propagation seamlessly.
// I wish if the first `makeFoo` were
// a syntactic sugar of the second one
func makeFoo(x: Int) throws -> Foo {
guard ... else {
throw FooError()| # 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 |