What is a ternary operator in programming?

This is a recommends products dialog
Top Suggestions
Starting at
View All >
Language
French
English
ไทย
German
繁體中文
Country
Hi
All
Sign In / Create Account
language Selector,${0} is Selected
Register & Shop at Lenovo Pro
Register at Education Store

Pro Tier Benefits

• Save up to an extra 5% on Think everyday pricing
• Spend ฿250,000 advance to Plus Tier with increased benefits

Plus Tier Benefits

• Save up to an extra 8% on Think everyday pricing
• Spend ฿750,000, advance for free to Elite Tier with increased benefits
• Take advantage of flexible payment options with TruScale Device as a Service.

Elite Tier Benefits

• Save up to an extra 12% on Think everyday pricing
• Take advantage of flexible payment options with
TruScale Device as a Service.
Reseller Benefits
• Access to Lenovo's full product portfolio
• Configure and Purchase at prices better than Lenovo.com
View All Details >
more to reach
PRO Plus
PRO Elite
Congratulations, you have reached Elite Status!
Pro for Business
Delete icon Remove icon Add icon Reload icon
TEMPORARILY UNAVAILABLE
DISCONTINUED
Temporary Unavailable
Cooming Soon!
. Additional units will be charged at the non-eCoupon price. Purchase additional now
We're sorry, the maximum quantity you are able to buy at this amazing eCoupon price is
Sign in or Create an Account to Save Your Cart!
Sign in or Create an Account to Join Rewards
View Cart
Wow, your cart is empty!
Remove
item(s) in cart
Fill it in with great deals
Some items in your cart are no longer available. Please visit cart for more details.
has been deleted
Please review your cart as items have changed.
of
Contains Add-ons
Proceed to Checkout
Yes
No
Popular Searches
What are you looking for today ?
Trending
Recent Searches
Hamburger Menu
{"arrowColor":"#000000","backgroundColor":"#e6f4fa","sideMsg":{"t_id":"","language":{"th":"","en_th":"","en":"","th_th":""},"id":""},"data":[{"pcInfo":"","mAndTabInfo":"","bannerInfo":{"t_id":"Pageb9f26a5e-8049-443d-b4b1-7d713f1084ab","language":{"th":"","en_th":"%3Cp%3E%3C%2Fp%3E%3Cp%3E%3Cstrong%3EYear%20End%20Holiday%20Sale%20%7C%20Get%20up%20to%2050%25%20off%20selected%20PCs%20%26amp%3B%20accessories%20for%20a%20limited%20time.%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2Fstrong%3E%3Ca%20href%3D%22%2Fd%2Fdeals%2Fonline-exclusive%2F%3FipromoID%3Dhellobar_01%22%20target%3D%22_self%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EShop%20Deals%3C%2Fstrong%3E%3C%2Fa%3E%3C%2Fp%3E","en":"","th_th":"%3Cp%3E%3C%2Fp%3E%3Cp%3E%3Cstrong%3E%E0%B9%82%E0%B8%9B%E0%B8%A3%E0%B9%82%E0%B8%A1%E0%B8%8A%E0%B8%B1%E0%B8%99%E0%B8%AA%E0%B9%88%E0%B8%87%E0%B8%97%E0%B9%89%E0%B8%B2%E0%B8%A2%E0%B8%9B%E0%B8%B5%20%7C%20%E0%B9%80%E0%B8%A7%E0%B8%A5%E0%B8%B2%E0%B8%88%E0%B8%B3%E0%B8%81%E0%B8%B1%E0%B8%94%3A%20%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%AA%E0%B9%88%E0%B8%A7%E0%B8%99%E0%B8%A5%E0%B8%94%E0%B8%AA%E0%B8%B9%E0%B8%87%E0%B8%AA%E0%B8%B8%E0%B8%94%2050%25%20%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%9E%E0%B8%B5%E0%B8%8B%E0%B8%B5%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%AD%E0%B8%B8%E0%B8%9B%E0%B8%81%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B9%80%E0%B8%AA%E0%B8%A3%E0%B8%B4%E0%B8%A1%26nbsp%3B%26nbsp%3B%3C%2Fstrong%3E%3Ca%20href%3D%22%2Fd%2Fdeals%2Fonline-exclusive%2F%3FipromoID%3Dhellobar_01%22%20target%3D%22_self%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B9%80%E0%B8%A5%E0%B8%B7%E0%B8%AD%E0%B8%81%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%AA%E0%B8%99%E0%B8%AD%E0%B8%95%E0%B9%88%E0%B8%B2%E0%B8%87%20%E0%B9%86%3C%2Fstrong%3E%3C%2Fa%3E%3C%2Fp%3E"},"id":"Pageb9f26a5e-8049-443d-b4b1-7d713f1084ab"},"gInfo":""},{"pcInfo":"","mAndTabInfo":"","bannerInfo":{"t_id":"Page42a92302-1bde-429e-b3f2-cece4e09f662","language":{"th":"","en_th":"%3Cp%3E%3Cstrong%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3C%2Fstrong%3E%3Cstrong%3ELenovo%20Pro%20for%20business%3C%2Fstrong%3E%20%7C%20FREE%20membership%2C%20exclusive%20member%20discounts%2C%20Purchase%20PC%20%26amp%3B%20get%2020%25%20off%20Accessories%3C%2Fp%3E%3Cp%3E%3Ca%20href%3D%22https%3A%2F%2Faccount.lenovo.com%2Fth%2Flenovopro%2Fen%2Fsmbaccount%2Fgatekeeper%2Fshowpage%3FipromoID%3Dhellobar_02_lpro%22%20target%3D%22_self%22%20textvalue%3D%22Join%20Now%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EJoin%20Now%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E","en":"","th_th":"%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cstrong%3E%3C%2Fstrong%3E%3Cstrong%3ELenovo%20Pro%20%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%98%E0%B8%B8%E0%B8%A3%E0%B8%81%E0%B8%B4%E0%B8%88%3C%2Fstrong%3E%20%7C%20%E0%B8%AA%E0%B8%A1%E0%B8%B1%E0%B8%84%E0%B8%A3%E0%B9%80%E0%B8%9B%E0%B9%87%E0%B8%99%E0%B8%AA%E0%B8%A1%E0%B8%B2%E0%B8%8A%E0%B8%B4%E0%B8%81%E0%B8%9F%E0%B8%A3%E0%B8%B5%20%E0%B8%9E%E0%B8%A3%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%AA%E0%B9%88%E0%B8%A7%E0%B8%99%E0%B8%A5%E0%B8%94%E0%B8%9E%E0%B8%B4%E0%B9%80%E0%B8%A8%E0%B8%A9%E0%B8%AA%E0%B8%B3%E0%B8%AB%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%AA%E0%B8%A1%E0%B8%B2%E0%B8%8A%E0%B8%B4%E0%B8%81.%20%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B8%9E%E0%B8%B5%E0%B8%8B%E0%B8%B5%E0%B9%81%E0%B8%A5%E0%B8%B0%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%AA%E0%B9%88%E0%B8%A7%E0%B8%99%E0%B8%A5%E0%B8%94%E0%B8%AD%E0%B8%B8%E0%B8%9B%E0%B8%81%E0%B8%A3%E0%B8%93%E0%B9%8C%E0%B9%80%E0%B8%AA%E0%B8%A3%E0%B8%B4%E0%B8%A1%2020%25%3C%2Fp%3E%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Ca%20href%3D%22https%3A%2F%2Faccount.lenovo.com%2Fth%2Flenovopro%2Fth%2Fsmbaccount%2Fgatekeeper%2Fshowpage%3FipromoID%3Dhellobar_02_lpro%22%20target%3D%22_self%22%20textvalue%3D%22%E0%B8%AA%E0%B8%A1%E0%B8%B1%E0%B8%84%E0%B8%A3%E0%B8%9F%E0%B8%A3%E0%B8%B5%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%99%E0%B8%B5%E0%B9%89%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B8%AA%E0%B8%A1%E0%B8%B1%E0%B8%84%E0%B8%A3%E0%B8%9F%E0%B8%A3%E0%B8%B5%E0%B8%95%E0%B8%AD%E0%B8%99%E0%B8%99%E0%B8%B5%E0%B9%89%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E"},"id":"Page42a92302-1bde-429e-b3f2-cece4e09f662"},"gInfo":""},{"pcInfo":"","mAndTabInfo":"","bannerInfo":{"t_id":"Page8906a26b-50bf-4a5d-9160-9f1c99a32092","language":{"th":"","en_th":"%3Cp%20style%3D%22text-wrap%3A%20wrap%3B%22%3ELenovo%20Education%20%7C%20Register%20to%20unlock%20THB3%2C800%20welcome%20discount%20%2B%20up%20to%2010%25%20EXTRA%20savings%26nbsp%3B%20%2B%2015%25%20off%20tablets.%3C%2Fp%3E%3Cp%20style%3D%22text-wrap%3A%20wrap%3B%22%3E%3Ca%20href%3D%22%2Fd%2Fschool-from-home%2F%3FipromoID%3DHellobar_03_edu_cat1%22%20target%3D%22_self%22%20textvalue%3D%22Shop%20Now%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EShop%20Now%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%26nbsp%3B%7C%26nbsp%3B%26nbsp%3B%3C%2Fspan%3E%3Ca%20href%3D%22https%3A%2F%2Fwww.lenovo.com%2Fth%2Fedu%2Fthedu%2Fen%2Flogin%2Fedu%2F%3FipromoID%3DHellobar_03_edu_cat2%22%20target%3D%22_self%22%20textvalue%3D%22Join%20Lenovo%20Education%26nbsp%3B%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EJoin%20Lenovo%20Education%3C%2Fstrong%3E%3Cstrong%3E%26nbsp%3B%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E","en":"","th_th":"%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cspan%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3ELenovo%20Education%26nbsp%3B%3C%2Fspan%3E%20%7C%20%E0%B8%A5%E0%B8%87%E0%B8%97%E0%B8%B0%E0%B9%80%E0%B8%9A%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%AA%E0%B9%88%E0%B8%A7%E0%B8%99%E0%B8%A5%E0%B8%94%E0%B8%95%E0%B9%89%E0%B8%AD%E0%B8%99%E0%B8%A3%E0%B8%B1%E0%B8%9A%20THB3%2C800%2B%20%E0%B8%9B%E0%B8%A3%E0%B8%B0%E0%B8%AB%E0%B8%A2%E0%B8%B1%E0%B8%94%E0%B8%9E%E0%B8%B4%E0%B9%80%E0%B8%A8%E0%B8%A9%2010%25%20%2B%2015%25%20%E0%B8%88%E0%B8%B2%E0%B8%81%E0%B9%81%E0%B8%97%E0%B9%87%E0%B8%9A%E0%B9%80%E0%B8%A5%E0%B9%87%E0%B8%95%3C%2Fp%3E%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Ca%20href%3D%22%2Fd%2Fschool-from-home%2F%3FipromoID%3DHellobar_03_edu_cat1%22%20target%3D%22_self%22%20textvalue%3D%22%E0%B9%80%E0%B8%A5%E0%B8%B7%E0%B8%AD%E0%B8%81%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%A5%E0%B8%A2%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B9%80%E0%B8%A5%E0%B8%B7%E0%B8%AD%E0%B8%81%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%A5%E0%B8%A2%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%26nbsp%3B%7C%26nbsp%3B%3C%2Fspan%3E%3Ca%20href%3D%22https%3A%2F%2Fwww.lenovo.com%2Fth%2Fedu%2Fthedu%2Fen%2Flogin%2Fedu%2F%3FipromoID%3DHellobar_03_edu_cat2%22%20target%3D%22_self%22%20textvalue%3D%22%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B8%A3%E0%B9%88%E0%B8%A7%E0%B8%A1%20Lenovo%20Education%26nbsp%3B%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B9%80%E0%B8%82%E0%B9%89%E0%B8%B2%E0%B8%A3%E0%B9%88%E0%B8%A7%E0%B8%A1%20Lenovo%20Education%26nbsp%3B%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E"},"id":"Page8906a26b-50bf-4a5d-9160-9f1c99a32092"},"gInfo":""},{"pcInfo":"","mAndTabInfo":"","bannerInfo":{"t_id":"Pagefb10d88b-98d4-463f-bd61-72df4e608c65","language":{"th":"","en_th":"%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%22%3EReady%2C%20set%2C%20grab%20your%20PC%20in%26nbsp%3B%20with%20Free%20shipping%20sitewide%2C%20no%20minimum%20Spend.%26nbsp%3B%3C%2Fspan%3E%3C%2Fp%3E%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%22%3ECall%201800-011-936.%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%3Ca%20href%3D%22%2Fd%2Fdeals%2Fexpress%2F%3FipromoID%3Dhellobar_04_quickship%22%20target%3D%22_blank%22%20style%3D%22text-wrap%3A%20nowrap%3B%20color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%20color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EShop%20Now%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fspan%3E%3C%2Fp%3E","en":"","th_th":"%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%22%3E%E0%B8%A3%E0%B8%B0%E0%B8%A7%E0%B8%B1%E0%B8%87%20%E0%B9%80%E0%B8%95%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%A1%E0%B8%95%E0%B8%B1%E0%B8%A7%20%E0%B8%84%E0%B8%A7%E0%B9%89%E0%B8%B2%E0%B8%9E%E0%B8%B5%E0%B8%8B%E0%B8%B5%E0%B8%82%E0%B8%AD%E0%B8%87%E0%B8%84%E0%B8%B8%E0%B8%93%20%E0%B8%88%E0%B8%B1%E0%B8%94%E0%B8%AA%E0%B9%88%E0%B8%87%E0%B8%9F%E0%B8%A3%E0%B8%B5%E0%B8%97%E0%B8%B8%E0%B8%81%E0%B8%84%E0%B8%B3%E0%B8%AA%E0%B8%B1%E0%B9%88%E0%B8%87%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%20%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B8%A1%E0%B8%B5%E0%B8%A2%E0%B8%AD%E0%B8%94%E0%B8%82%E0%B8%B1%E0%B9%89%E0%B8%99%E0%B8%95%E0%B9%88%E0%B8%B3%26nbsp%3B%3C%2Fspan%3E%3C%2Fp%3E%3Cp%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%22%3E%E0%B9%82%E0%B8%97%E0%B8%A3%201800-011-936%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%3Ca%20href%3D%22%2Fd%2Fdeals%2Fexpress%2F%3FipromoID%3Dhellobar_04_quickship%22%20target%3D%22_blank%22%20textvalue%3D%22%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%A5%E0%B8%A2%22%20style%3D%22text-wrap%3A%20nowrap%3B%20color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22text-wrap%3A%20nowrap%3B%20color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%A5%E0%B8%A2%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fspan%3E%3C%2Fp%3E"},"id":"Pagefb10d88b-98d4-463f-bd61-72df4e608c65"},"gInfo":""},{"pcInfo":"","mAndTabInfo":"","bannerInfo":{"t_id":"Pageeba91e10-20af-4486-b9a2-882a76408bb2","language":{"th":"","en_th":"%3Cp%3E%3Cspan%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3EYoga%20Slim%207i%20(14%26%2339%3B%26%2339%3B%2C%20Gen%209)%7CUnlock%20seamless%20AI-powered%20creativity%20with%20Intel%C2%AE%20Core%E2%84%A2%20Ultra%20processors%20in%20a%20thin%2C%20light%20design%20with%20epic%20battery%20life.%26nbsp%3B%26nbsp%3B%3C%2Fspan%3E%3Ca%20href%3D%22%2Fp%2Flaptops%2Fyoga%2Fyoga-slim-series%2Fyoga-slim-7i-gen-9-aura-edition-15-inch-intel%2Flen101y0051%3FipromoID%3Dhellobar_05_Yoga_Slim_7i_Gen_9%22%20target%3D%22_self%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3EShop%20Now%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E","en":"","th_th":"%3Cp%3E%3Cspan%20style%3D%22text-wrap-mode%3A%20wrap%3B%22%3EYoga%20Slim%207i%20(14%26%2339%3B%26%2339%3B%2C%20Gen%209)%7C%E0%B8%9B%E0%B8%A5%E0%B8%94%E0%B8%A5%E0%B9%87%E0%B8%AD%E0%B8%84%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%84%E0%B8%B4%E0%B8%94%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87%E0%B8%AA%E0%B8%A3%E0%B8%A3%E0%B8%84%E0%B9%8C%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%82%E0%B8%B1%E0%B8%9A%E0%B9%80%E0%B8%84%E0%B8%A5%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%99%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%20AI%20%E0%B9%84%E0%B8%94%E0%B9%89%E0%B8%AD%E0%B8%A2%E0%B9%88%E0%B8%B2%E0%B8%87%E0%B8%A3%E0%B8%B2%E0%B8%9A%E0%B8%A3%E0%B8%B7%E0%B9%88%E0%B8%99%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2%E0%B8%82%E0%B8%B8%E0%B8%A1%E0%B8%9E%E0%B8%A5%E0%B8%B1%E0%B8%87%20Intel%C2%AE%20Core%E2%84%A2%20Ultra%20%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%94%E0%B8%B5%E0%B9%84%E0%B8%8B%E0%B8%99%E0%B9%8C%E0%B8%9A%E0%B8%B2%E0%B8%87%E0%B9%80%E0%B8%9A%E0%B8%B2%E0%B8%9E%E0%B8%A3%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%AD%E0%B8%B2%E0%B8%A2%E0%B8%B8%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89%E0%B8%87%E0%B8%B2%E0%B8%99%E0%B9%81%E0%B8%9A%E0%B8%95%E0%B9%80%E0%B8%95%E0%B8%AD%E0%B8%A3%E0%B8%B5%E0%B9%88%E0%B8%97%E0%B8%B5%E0%B9%88%E0%B8%A2%E0%B8%B2%E0%B8%A7%E0%B8%99%E0%B8%B2%E0%B8%99%26nbsp%3B%20%26nbsp%3B%3C%2Fspan%3E%3Ca%20href%3D%22%2Fp%2Flaptops%2Fyoga%2Fyoga-slim-series%2Fyoga-slim-7i-gen-9-aura-edition-15-inch-intel%2Flen101y0051%3FipromoID%3Dhellobar_05_Yoga_Slim_7i_Gen_9%22%20target%3D%22_self%22%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%20text-decoration%3A%20underline%3B%22%3E%3Cspan%20style%3D%22color%3A%20rgb(0%2C%200%2C%200)%3B%22%3E%3Cstrong%3E%E0%B8%8B%E0%B8%B7%E0%B9%89%E0%B8%AD%E0%B9%80%E0%B8%A5%E0%B8%A2%3C%2Fstrong%3E%3Cstrong%3E%3C%2Fstrong%3E%3C%2Fspan%3E%3C%2Fa%3E%3C%2Fp%3E"},"id":"Pageeba91e10-20af-4486-b9a2-882a76408bb2"},"gInfo":""}],"autoRun":true,"displayTerminal":"pc,tablet,mobile"}
 


What is a ternary operator in programming?

A ternary operator is a conditional operator in programming that takes three operands and evaluates an expression based on a condition. It is commonly represented as "condition? expression1: expression2" in many programming languages.

How does the ternary operator differ from an if-else statement?

The ternary operator is a concise way to write conditional statements compared to if-else statements. It condenses the logic into a single line of code, making it useful for simple conditions. In contrast, if-else statements provide more flexibility and can handle complex conditions and multiple code blocks.

Where can the ternary operator be used in programming?

The ternary operator can be used in various programming contexts, such as assigning values to variables, determining the return value of a function, or specifying conditions in control flow statements.

When should I use the ternary operator?

The ternary operator is ideal for short and straightforward conditional statements that do not require extensive branching or complex logic. It is commonly used for assigning values based on a condition or simplifying conditional return statements.

Why is the ternary operator useful?

The ternary operator enhances code readability by condensing simple conditional logic into a compact expression. It reduces the number of lines of code needed and can make the intention of the condition more explicit.

How does the ternary operator handle nested conditions?

The ternary operator allows nesting, but excessive nesting can lead to code that is difficult to read and understand. It's important to use nested ternary operators judiciously and consider alternative approaches, such as if-else statements or switch-case statements, for more complex conditions.

What happens if I omit the middle expression in the ternary operator?

Omitting the middle expression in the ternary operator is not valid syntax in most programming languages. It is essential to provide both the expressions for the true and false conditions.

Are there any limitations or caveats when using the ternary operator?

While the ternary operator is powerful for concise conditional statements, it should be used judiciously. Excessive or convoluted ternary expressions can decrease code readability and maintainability. It is recommended to prioritize clarity over brevity.

How does the ternary operator handle type coercion?

The ternary operator follows the rules of type coercion in the programming language being used. It converts the operands to a common type if necessary, before evaluating the expression.

Can I use the ternary operator in all programming languages?

Not all programming languages support the ternary operator. However, it is a common feature in many popular languages like C, C++, Java, JavaScript, Python, and hypertext preprocessor (PHP).

How does the ternary operator impact code performance?

The ternary operator generally has no significant impact on code performance. Modern compilers and interpreters optimize the code, and any performance differences between the ternary operator and if-else statements are negligible.

What are some common mistakes to avoid when using the ternary operator?

Common mistakes include complex nested expressions, omitting one of the expressions, or using the ternary operator for conditions that require more extensive branching. It is important to use proper parentheses and consider readability when using the ternary operator.

Why is the ternary operator sometimes called the "conditional operator"?

The ternary operator is often referred to as the "conditional operator" because it allows the execution of different expressions based on a condition. The term "ternary" refers to the fact that it takes three operands.

How does the ternary operator handle short-circuit evaluation?

The ternary operator follows short-circuit evaluation, meaning that only the expression corresponding to the evaluated condition is executed. This behavior can be leveraged to conditionally execute code based on the outcome of the ternary operator.

Can the ternary operator be used for more than one condition?

No, the ternary operator only evaluates a single condition. If multiple conditions need to be checked, logical operators (e.g., && and ||) or nested ternary operators can be used to combine the conditions.

How does the ternary operator affect code maintainability?

While the ternary operator can improve code readability in certain cases, excessive use or complex expressions can reduce code maintainability. It is important to strike a balance between using the ternary operator and other control flow constructs to ensure code is understandable by others.

Why is the ternary operator often favored by experienced programmers?

Experienced programmers often appreciate the ternary operator for its conciseness and ability to express simple conditions in a single line of code. It can make the code more readable and easier to understand, especially for developers familiar with the language.

Can the ternary operator lead to code that is difficult to debug?

The ternary operator, when used appropriately, does not necessarily lead to code that is difficult to debug. However, complex expressions or nested conditions can make debugging more challenging. It is crucial to write clear and well-tested code when using the ternary operator.

What is the precedence of the ternary operator compared to other operators?

The ternary operator usually has lower precedence than most other operators, including arithmetic and logical operators. However, its precedence can be adjusted using parentheses to control the order of evaluation within a larger expression.

Are there any best practices for using the ternary operator?

Some best practices for using the ternary operator include keeping expressions simple and concise, avoiding excessive nesting, prioritizing code clarity over brevity, and documenting complex logic. Additionally, following the coding style guidelines of the language or project can promote consistency.

How does the ternary operator handle short-circuit evaluation with multiple conditions?

Short-circuit evaluation in the ternary operator occurs only for the evaluated condition. If multiple conditions are present, the subsequent conditions will be evaluated regardless of the outcome of the previous conditions.

Can I use the ternary operator for error handling or exception handling?

While the ternary operator can be used to handle certain error conditions, it is generally not recommended for complex error handling or exception handling scenarios. In such cases, using dedicated error handling mechanisms like try-catch blocks or custom error handling functions is more appropriate.

How does the ternary operator handle precedence when used with other operators?

The ternary operator follows the precedence rules defined by the programming language. If used in combination with other operators, parentheses can be used to explicitly specify the order of evaluation and ensure the desired behavior.

{"pageComponentDataId":"f2a97040iaf38-4268-8aa4-dd300dbb82b5","isAssociatedRelease":"true","pageComponentDataLangCode":"en_th","configData":{"jumpType":"currentTab","headlineColor":"black","displayNumber":"","styleMode":"vertical","miniCardHoMode":"2","headline":"","products":[{"number":{"t_id":"len101t0102","language":{"th":"","en_th":"len101t0102","en":"","th_th":"len101t0102"},"id":"Page7e482a24-5af5-4d33-86a4-3471790a1816"}},{"number":{"t_id":"len101t0104","language":{"th":"","en_th":"len101t0104","en":"","th_th":"len101t0104"},"id":"Page45f8851e-4b9b-44a0-ab20-7facb007acf4"}},{"number":{"t_id":"len101t0081","language":{"th":"","en_th":"len101t0081","en":"","th_th":"len101t0081"},"id":"Pagedc7cb422-7f94-44a3-88ce-f9e3a06ffc33"}},{"number":{"t_id":"len101g0036","language":{"th":"","en_th":"len101g0036","en":"","th_th":"len101g0036"},"id":"Pageb7e97ced-9d08-43f3-8c2e-62151abf86af"}}]},"urlPrefix":"AAAAAAALAAAE","needGetLatestTransDataKey":"needGetLatestTransDataValue","title":"glossary-right-blue-boxes-fragment","pageId":"8e408484-13ce-4c08-8240-4640f5264241","urlEdit":0,"uri":"/FragmentDirectory/glossary/glossary-right-blue-boxes-fragment.frag","pageComponentId":"f2a97040iaf38-4268-8aa4-dd300dbb82b5","tplId":"c7389f9a-59c0-4c34-a9e1-f1c090c6ab86","pageComponentUuid":"f2a97040iaf38-4268-8aa4-dd300dbb82b5","targetUser":"0"}
coming coming
Starting at
List Price
Est Value
Web Price:
List Price
Est Value (Estimated Value)
List Price is Lenovo’s estimate of product value based on the industry data, including the prices at which first and third-party retailers and etailers have offered or valued the same or comparable products. Third-party reseller data may not be based on actual sales.
Estimated value is Lenovo’s estimate of product value based on industry data, including the prices at which Lenovo and/or third-party retailers and e-tailers have offered or valued the same or comparable products. Third-party data may not be based on actual sales.
Learn More
See More
See Less
View {0} Model
View {0} Models
shipping.options.for.{0}
Part Number:
Features
See More
See Less
compare
Added!
Great choice!
You may compare up to 4 products per product category (laptops, desktops, etc). Please de-select one to add another.
View Your Comparisons
Add To Cart
Add To Cart
We're sorry,
Products are temporarily unavailable.
Continue Shopping
Learn More
Coming Soon
Featured Product
Featured Products
Oops! No results found. Visit the categories above to find your product.
Save
open in new tab
© 2024 Lenovo. All rights reserved.
© {year} Lenovo. All rights reserved.
Email address is required
Compare  ()
x