[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"academy-blogs-th-1-1-all-enhance-program-intelligence-with-if-else-go-ep3-all--*":3,"academy-blog-translations-ytz22o0fle9leiy":80},{"data":4,"page":67,"perPage":67,"totalItems":67,"totalPages":67},[5],{"alt":6,"collectionId":7,"collectionName":8,"content":9,"cover_image":10,"cover_image_path":11,"created":12,"created_by":13,"expand":14,"id":75,"keywords":76,"locale":49,"published_at":77,"scheduled_at":13,"school_blog":71,"short_description":78,"status":69,"title":6,"updated":79,"updated_by":13,"slug":72,"views":74},"EP.3 เพิ่มความฉลาดให้โปรแกรมด้วย If-Else ใน Go","sclblg987654321","school_blog_translations","\u003Cp>\u003Cspan style=\"font-size:20px;\">\u003Cstrong>เพิ่มความฉลาดให้โปรแกรมด้วย If-Else ใน Go\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fp>\u003Cp>เคยสงสัยไหมว่าโปรแกรมตัดสินใจอย่างไร? เช่น ถ้าข้อมูลถูกต้องให้ดำเนินการต่อ ถ้าไม่ถูกต้องให้แจ้งเตือน? นี่คือหน้าที่ของ If-Else ที่ช่วยให้โปรแกรมตัดสินใจได้อย่างชาญฉลาด&nbsp;\u003C\u002Fp>\u003Cp>If-Else คืออะไร? ในทุกโปรแกรม เราต้องการการตัดสินใจ เช่น ถ้าผู้ใช้กรอกข้อมูลถูกต้องให้เข้าสู่ระบบ ถ้าผิดให้แจ้งเตือน error การใช้ If-Else จะช่วยให้โปรแกรมสามารถทำงานตามเงื่อนไขได้\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">package main\r\n\r\nimport \"fmt\"\r\n\r\nfunc main() {\r\n    age := 20\r\n    if age &gt;= 18 {\r\n        fmt.Println(\"You are an adult.\")\r\n    } else {\r\n        fmt.Println(\"You are not an adult.\")\r\n    }\r\n}\r\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>โครงสร้างของ If-Else ใน Go\u003C\u002Fstrong>\u003C\u002Fspan>\u003C\u002Fp>\u003Cul style=\"list-style-type:circle;\">\u003Cli>if condition {}: ถ้าเงื่อนไขเป็นจริง จะทำงานในบล็อกนี้\u003C\u002Fli>\u003Cli>else {}: ถ้าเงื่อนไขไม่เป็นจริง จะทำงานในบล็อกนี้\u003C\u002Fli>\u003C\u002Ful>\u003Cp>คุณสามารถเพิ่มเงื่อนไขได้หลายชั้นด้วย else if เช่น:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">score := 85\r\nif score &gt;= 90 {\r\n    fmt.Println(\"Grade A\")\r\n} else if score &gt;= 80 {\r\n    fmt.Println(\"Grade B\")\r\n} else {\r\n    fmt.Println(\"Grade C\")\r\n}\r\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>&nbsp;\u003C\u002Fp>\u003Cp>\u003Cspan style=\"font-size:18px;\">\u003Cstrong>การใช้ตัวดำเนินการ (Comparison Operators)\u003C\u002Fstrong>\u003C\u002Fspan>\u003Cbr>การเขียนเงื่อนไขใน If-Else เราใช้ตัวดำเนินการเปรียบเทียบ เช่น:\u003C\u002Fp>\u003Cul>\u003Cli>== เท่ากับ\u003C\u002Fli>\u003Cli>!= ไม่เท่ากับ\u003C\u002Fli>\u003Cli>&gt; มากกว่า\u003C\u002Fli>\u003Cli>&lt; น้อยกว่า\u003C\u002Fli>\u003Cli>&gt;= มากกว่าหรือเท่ากับ\u003C\u002Fli>\u003Cli>&lt;= น้อยกว่าหรือเท่ากับ\u003C\u002Fli>\u003C\u002Ful>\u003Cp>ตัวอย่าง:\u003C\u002Fp>\u003Cpre>\u003Ccode class=\"language-plaintext\">number := 10\r\nif number % 2 == 0 {\r\n    fmt.Println(\"Even number\")\r\n} else {\r\n    fmt.Println(\"Odd number\")\r\n}\r\u003C\u002Fcode>\u003C\u002Fpre>\u003Cp>\u003Cspan style=\"background-color:rgb(240,242,245);color:rgb(8,8,9);font-family:&quot;Segoe UI Historic&quot;, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif;font-size:15px;\">\u003Cspan style=\"-webkit-text-stroke-width:0px;display:inline !important;float:none;font-style:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-weight:400;letter-spacing:normal;orphans:2;text-align:start;text-decoration-color:initial;text-decoration-style:initial;text-decoration-thickness:initial;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;\">ทั้งหมดนี้จะช่วยให้ผู้เรียนเข้าใจการควบคุมการทำงานของโปรแกรมด้วย If-Else ซึ่งเป็นพื้นฐานสำคัญในการสร้างโปรแกรมที่ฉลาดขึ้น\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fp>\u003Cp>&nbsp;\u003C\u002Fp>","4_11zon_w7een6aaq9.webp","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclblg987654321\u002Fznypcyct0x2n4c1\u002F4_11zon_w7een6aaq9.webp","2026-03-04 08:34:32.184Z","",{"keywords":15,"locale":43,"school_blog":53},[16,23,28,33,38],{"collectionId":17,"collectionName":18,"created":19,"created_by":13,"id":20,"name":21,"updated":22,"updated_by":13},"sclkey987654321","school_keywords","2026-03-04 08:34:25.224Z","i9bl5yxbuh8vdw3","else if","2026-04-10 16:08:14.236Z",{"collectionId":17,"collectionName":18,"created":24,"created_by":13,"id":25,"name":26,"updated":27,"updated_by":13},"2026-03-04 08:34:31.166Z","8yutfu15riv7rkc","ควบคุมโฟลว์","2026-04-10 16:08:16.370Z",{"collectionId":17,"collectionName":18,"created":29,"created_by":13,"id":30,"name":31,"updated":32,"updated_by":13},"2026-03-04 08:31:30.863Z","oyltq82epf0vqka","การเขียนโปรแกรม","2026-04-10 16:07:41.883Z",{"collectionId":17,"collectionName":18,"created":34,"created_by":13,"id":35,"name":36,"updated":37,"updated_by":13},"2026-03-04 08:20:11.547Z","ey3puyme01a9bsw","Go","2026-04-10 16:07:25.893Z",{"collectionId":17,"collectionName":18,"created":39,"created_by":13,"id":40,"name":41,"updated":42,"updated_by":13},"2026-03-04 08:34:28.167Z","vbpls11idbswpbf","If-Else","2026-04-10 16:08:15.206Z",{"code":44,"collectionId":45,"collectionName":46,"created":47,"flag":48,"id":49,"is_default":50,"label":51,"updated":52},"th","pbc_1989393366","locales","2026-01-22 10:59:55.832Z","twemoji:flag-thailand","s8wri3bt4vgg2ji",true,"Thai","2026-04-10 15:42:46.614Z",{"category":54,"collectionId":55,"collectionName":56,"created":13,"expand":57,"id":71,"slug":72,"updated":73,"views":74},"wqxt7ag2gn7xcmk","pbc_2105096300","school_blogs",{"category":58},{"blogIds":59,"collectionId":60,"collectionName":61,"created":62,"created_by":13,"id":54,"image":63,"image_alt":13,"image_path":64,"label":65,"name":66,"priority":67,"publish_at":68,"scheduled_at":13,"status":69,"updated":70,"updated_by":13},[],"sclcatblg987654321","school_category_blogs","2026-03-04 08:33:53.210Z","59ty92ns80w_15oc1implw.png","https:\u002F\u002Ftwsme-r2.tumwebsme.com\u002Fsclcatblg987654321\u002Fwqxt7ag2gn7xcmk\u002F59ty92ns80w_15oc1implw.png",{"en":66,"th":66},"Golang The Series",1,"2026-03-16 04:39:38.440Z","published","2026-04-25 02:32:15.470Z","ytz22o0fle9leiy","enhance-program-intelligence-with-if-else-go-ep3","2026-05-06 22:15:21.994Z",484,"znypcyct0x2n4c1",[20,25,30,35,40],"2025-01-21 07:02:37.746Z","เรียนรู้การใช้ If-Else และ else if ในภาษา Go เพื่อควบคุมการทำงานของโปรแกรมอย่างมีประสิทธิภาพ","2026-04-25 02:47:33.139Z",{"th":72,"en":72}]