{"id":403,"date":"2021-09-17T15:22:52","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/swift.tecc0.com\/?p=403"},"modified":"2021-09-17T15:22:52","modified_gmt":"1970-01-01T00:00:00","slug":"post-403","status":"publish","type":"post","link":"https:\/\/swift.tecc0.com\/?p=403","title":{"rendered":"Swift\u306eenum\u3067\u30e1\u30bd\u30c3\u30c9(method)\u3092\u5b9a\u7fa9\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>Swift\u306e<strong>enum<\/strong>\u306f\u3051\u3063\u3053\u3046\u3044\u308d\u3093\u306a\u3053\u3068\u304c\u3067\u304d\u3066\u3001\u305d\u306e\u4e00\u3064\u306b<strong>enum\u5185\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b<\/strong>\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>Swift\u3067enum\u5185\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b<\/h3>\n<pre class=\"lang:swift decode:true \">enum Fruits: String {\r\n    case Apple = \"\u308a\u3093\u3054\"\r\n    case Banana = \"\u3070\u306a\u306a\"\r\n    case Orange = \"\u304a\u308c\u3093\u3058\"\r\n    \r\n    func getPrice() -&gt; Int {\r\n        switch self {\r\n            case .Apple:\r\n                return 100\r\n            case .Banana:\r\n                return 50\r\n            case .Orange:\r\n                return 120\r\n        }\r\n    }\r\n}\r\n\r\nprint(Fruits.Apple.getPrice()) \/\/ 100\r\nprint(Fruits.Orange.getPrice()) \/\/ 120<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067enum\u5185\u306b\u5ba3\u8a00\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u3092\u7c21\u5358\u306b\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u4ed6\u306b\u3082\u3044\u308d\u3044\u308d\u3042\u308b\u304c\u3001<strong>Swift\u306eenum\u6700\u5f37\u304b\u3088\uff1f<\/strong>\u3063\u3066\u611f\u3058\u304c\u3051\u3063\u3053\u3046\u3042\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Swift\u306eenum\u306f\u3051\u3063\u3053\u3046\u3044\u308d\u3093\u306a\u3053\u3068\u304c\u3067\u304d\u3066\u3001\u305d\u306e\u4e00\u3064\u306benum\u5185\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u5b9a\u7fa9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002 &nbsp; Swift\u3067enum\u5185\u306b\u30e1\u30bd\u30c3\u30c9\u3092\u8ffd\u52a0\u3059\u308b enum Fruits: String { case &#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\/403"}],"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=403"}],"version-history":[{"count":2,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions"}],"predecessor-version":[{"id":405,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/403\/revisions\/405"}],"wp:attachment":[{"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swift.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}