Inline class nedir ?

Oca 05, 2022

2 Yorum


Daha önce hiç value-based class diye bir şey duydunuz mu? Aslında olay çok basit ama çok etkili haydi beraber inceleyelim 😎

Senaryomuz şöyle, 

Bir çalışanımız var ve bunun bir Id 'si var. Bu Id ile para yolladığımız bir func yazalım.

fun sendMoneyToUser(money: Int, userId: Int) { // Para gönderiliyor..}

val userId = 1

// dikkat edin userId ve paranın yerlerini yanlış yazdım :(
sendMoneyToUser(userId, 1_000)

Yukardaki durumun korunabilimesi gerekiyor. Çünkü yanlış yazmama rağmen çalışabilmesi ve başka bir çalışana para gitmesi çok olasıdır. Peki nasıl çözebiliriz ?

// inline class 
value class UserId(val id: Int)

fun sendMoneyToUser(salary: Int, UserId: Int) { // Para gönderiliyor..} 

val userId = UserId(1)
sendMoneyToUser(userId, 1_000) // Compile time error. Burası çalışmaz bile :)

Yukardaki koda bakınca aslında çok basitçe wrapper bir class yarattık.

  • Sadece bir property ile primary constructer'ı olabilir ! 

  • const val olarak kullanılamazlar!

  • init constructer'ları vardır ve require özelliği ile run time validation yapılabilir.

Daha fazla detay için sayfasını ziyaret edebilirsiniz. Sağlıklı günler


class inline kotlin

Benzer Yazılar


June 04, 202302:07

Hey Fellow Business Owner, Hope this message finds you crushing it in the online marketing game. I've got something epic to share with you today that'll blow your mind and take your Google My Business (GMB) domination to a whole new level. Buckle up, my friend, because it's time to introduce you to CTR Booster ( – the ultimate weapon for click-through rate optimization. You know how crucial it is to make your GMB listing stand out, right? Well, get ready to leave your competitors in the dust. CTR Booster, developed by the geniuses at, is designed to skyrocket your click-through rate and make your GMB listing the irresistible choice for potential customers. Check out the insane benefits of adding CTR Booster to your SEO arsenal: Crush Your CTR Records: CTR Booster employs wickedly advanced algorithms and battle-tested strategies to optimize your click-through rate on GMB. Kiss average CTRs goodbye, my friend. Get ready to shatter your KPI's and watch as your listing climbs to the top, leaving competitors scratching their heads. Outrank and Outshine: Time to go from average Joe to SEO superhero. With CTR Booster, you can outperform your competitors, leaving them in the dust. Manipulate that click-through rate like a boss and secure top rankings on GMB. You'll become the local legend everyone looks up to, while others wonder how the heck you did it. Traffic Galore: Picture this – a stampede of highly targeted traffic rushing to your business. CTR Booster makes it happen. By optimizing your click-through rate, you'll attract a swarm of potential customers who can't resist clicking on your listing. Get ready to welcome more foot traffic, more inquiries, and more sales than ever before. Now, here's the kicker. I've managed to score you an exclusive 30% discount on CTR Booster ( That's right, my friend, a whopping 30% off to unlock the true power of click-through rate manipulation. Just click on this link now ( to claim your copy of CTR Booster and lock in your low price. Don't let this opportunity slip through your fingers. Take action now and grab your unfair advantage in the SEO game. Head over to our website [] to learn more about CTR Booster and secure your copy today. And hey, if you've got any questions or need ninja-level support, my team is ready to rock and roll. Prepare to dominate GMB like never before with CTR Booster. Don't forget to use promo code BOOST30 to claim your 30% discount! Cheers, SEO Enthusiast and Traffic Ninja CTR Booster Sales Rep Max Winters

February 27, 202315:51

Have you ever had difficulty writing content? Do you want an easier way to create compelling, engaging content faster? Introducing Jasper AI, the revolutionary artificial intelligence (AI) writing software. Jasper AI was designed to help everyone who struggles to write content quickly and effectively. It works by taking your ideas and producing written content that is accurate, effective, and tailored to your audience. Jasper AI's unique AI writing capabilities are a game changer in the content creation world. Our AI engine learns after every text you write and helps you create higher quality content faster. Whether it's a social media post, an email, or a blog post -- Jasper AI has you covered. What are the benefits of using Jasper AI? • Generate content quickly. You can produce written content in just a few minutes. • Improve the accuracy of your written content. Our AI engine can identify mistakes and help you correct them. • Handle large projects with ease. Jasper AI can easily manage large and complex projects. • Save time and money. Reduce the editing time needed for written content and save valuable resources. We understand that creating great content can be a challenge, so why not make it easier with the help of Jasper AI? Try Jasper AI today for free at and see how you can create great content faster.