{"id":320,"date":"2021-09-17T15:23:07","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/swift.tecc0.com\/?p=320"},"modified":"2021-09-17T15:23:07","modified_gmt":"1970-01-01T00:00:00","slug":"post-320","status":"publish","type":"post","link":"https:\/\/swift.tecc0.com\/?p=320","title":{"rendered":"Swift\u3067\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u95a2\u6570\u3092\u4f7f\u3046\u65b9\u6cd5"},"content":{"rendered":"<p><strong>\u30b8\u30a7\u30cd\u30ea\u30af\u30b9<\/strong>\u3068\u306f\u306a\u3093\u305e\u3084\u3068\u3044\u3046\u8a71\u3067\u3059\u304c\u3001\u660e\u793a\u7684\u306b\u578b\u3092\u6307\u5b9a\u305b\u305a\u3001\u67d4\u8edf\u306b\u51e6\u7406\u3092\u884c\u3048\u308b\u3088\u3046\u306a\u3082\u306e\u3092\u8a00\u3046\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u51e6\u7406\u3092\u898b\u305f\u307b\u3046\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3046\u306e\u3067\u66f8\u304f\u306d\u3002<\/p>\n<h3>Swift\u3067\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u3092\u4f7f\u3046<\/h3>\n<pre class=\"lang:swift decode:true \">func max&lt;T: Comparable&gt; (x: T, y: T) -&gt; T {\n\/\/    if x &gt; y {\n\/\/        return x\n\/\/    } else {\n\/\/        return y\n\/\/    }\n    \/\/ \u4e0a\u3068\u540c\u3058\u610f\u5473\n    return x &gt; y ? x : y\n}\n\n\/\/ Int\u3067\u4f7f\u3046\nprint(max(x: 5, y: 10)) \/\/ 10\nprint(max(x: 39, y: 13)) \/\/ 39\n\n\/\/ String\u3067\u4f7f\u3046\nprint(max(x: \"a\", y: \"z\")) \/\/ \"z\"\nprint(max(x: \"hoge\", y: \"fuga\")) \/\/ \"hoge\"<\/pre>\n<p>\u547c\u3073\u51fa\u3057\u5074\u3067\u308f\u304b\u308b\u3088\u3046\u306b\u3001Int\u3067\u3082\u95a2\u6570\u3092\u4f7f\u3063\u3066\u308b\u3057\u3001String\u3067\u3082\u554f\u984c\u306a\u304f\u4f7f\u3048\u3066\u308b\u3088\u3002<\/p>\n<p>\u4eca\u56de\u306emax\u95a2\u6570\u306f\u3001\u6570\u5b57\u3067\u306f\u5927\u304d\u3044\u65b9\u3001\u6587\u5b57\u3067\u306f\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\u9806\u304c\u5f8c\u306e\u65b9\u3092\u8fd4\u3057\u3066\u308b\u3088\u3002<\/p>\n<p>\u3061\u306a\u307f\u306b\u4eca\u56de\u306f T \u3092\u4f7f\u3063\u3066\u308b\u3051\u3069\u3001\u4f55\u3067\u3082\u3044\u3044\u3088\u3002<\/p>\n<p>\u6163\u7fd2\u7684\u306bT\u3092\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u3053\u3060\u308f\u308a\u304c\u306a\u3051\u308c\u3070T\u3092\u4f7f\u304a\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u3068\u306f\u306a\u3093\u305e\u3084\u3068\u3044\u3046\u8a71\u3067\u3059\u304c\u3001\u660e\u793a\u7684\u306b\u578b\u3092\u6307\u5b9a\u305b\u305a\u3001\u67d4\u8edf\u306b\u51e6\u7406\u3092\u884c\u3048\u308b\u3088\u3046\u306a\u3082\u306e\u3092\u8a00\u3046\u3002 \u5b9f\u969b\u306b\u51e6\u7406\u3092\u898b\u305f\u307b\u3046\u304c\u308f\u304b\u308a\u3084\u3059\u3044\u3068\u601d\u3046\u306e\u3067\u66f8\u304f\u306d\u3002 Swift\u3067\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u3092\u4f7f\u3046 func max&lt;T: Co&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/320"}],"collection":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320"}],"version-history":[{"count":4,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":786,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/320\/revisions\/786"}],"wp:attachment":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}