This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scalaは言わずものかな | |
val f:Int => Int = args.headOption match { | |
case Some(value) => x => + catching(classOf[NumberFormatException]).opt(value.toInt).getOrElse(0) | |
case None => x => x | |
} | |
// そもそも宣言で型がわかっているので | |
val f1:Int => Int = args.headOption match { | |
case Some(value) => _ + catching(classOf[NumberFormatException]).opt(value.toInt).getOrElse(0) | |
case None => _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dim i As Integer | |
' それVBならBuildできますよ? | |
Dim f As Func(Of Integer, Integer) = If(args.Any() AndAlso Integer.TryParse(args.First(), i), Function(x) x + i, Function(x) x) | |
' 左に型を明記する必要すらない | |
Dim f1 = If(args.Any() AndAlso Integer.TryParse(args.First(), i), Function(x As Integer) x + i, Function(x As Integer) x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Type of conditional expression cannot be determined because there is no implicit conversion between 'lambda expression' and 'lambda expression' | |
Func<int, int> f = args.Any() && int.TryParse(args.First(), out var i) ? x => x + i : x => x; | |
// 型を書いても無駄 | |
Func<int, int> f1 = args.Any() && int.TryParse(args.First(), out var i) ? (int x) => x + i : (int x) => x; | |
// OK : args.Any() && int.TryParse(args.First(), out var j) ? (Func<int, int>)(x => x + j) : x => x の型が `Func<int, int>` に確定するので | |
Func<int, int> f2 = args.Any() && int.TryParse(args.First(), out var j) ? (Func<int, int>)(x => x + j) : x => x; | |
var f3 = args.Any() && int.TryParse(args.First(), out var k) ? (Func<int, int>)(x => x + k) : x => x; | |
// OK : この'lambda expression'と `Func<int, int>` との間には implicit conversion が成立する | |
Func<int, int> f4 = x => x + (args.Any() && int.TryParse(args.First(), out var arg) ? arg : 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Sample | |
{ | |
class Entity | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Text; | |
namespace ConsoleApplication | |
{ | |
class Program | |
{ | |
interface IHoge<out T> | |
{ | |
T Foo(); | |
} |