Ana sayfa Genel Swift – Bir değerin array’de olup olmadığını kontrol etme

Swift – Bir değerin array’de olup olmadığını kontrol etme



Bu dersimizde basitçe bir array’in içinde herhangi bir elemanın olup olmadığını kontrol etmeyi göreceğiz.

Önce aşağıdaki kod bloğunu playground’a yazıp gelen çıktıları inceleyelim.

Öncelikle sebzeler adında Stringlerden oluşan bir array oluşturuyoruz. Sonrasında “.contains()” metoduyla, o array’in belirttiğimiz Stringe sahip olup olmadığını kontrol edebiliyoruz.

Birinci if-else bloğumuzda, arrayimiz içerisinde Domates stringini barındırdığı için çıktı olarak “Buyrun, bir adet domates :P” yazısını görebiliyoruz.

Ancak ikinci if-else bloğumuzda, arrayimizde Ispanak stringi olmadığı için, .contains metodu false oluyor ve else durumuna düşerek, “Üzgünüz ıspanak yok :(” çıktısını alıyoruz.

Gördüğünüz gibi .contains() metodunu kullanarak, kolayca arraylerimizde bir objenin olup olmadığını kontrol edebiliyoruz.

Önceki makaleUdemyde 1 Yıl!
Sonraki makaleSymPy ile Calculus hesaplamaları – Bölüm 3 (Seri açılımları)
Kadir Has Universitesi Elektrik&Elektronik Bölümünden 2016 yılında mezun oldum, mezuniyet sonrası alan değiştirerek bilgisayar bilimi ve programlama üzerine çalışmalarıma başladım. Amacım kendimi geliştirirken bir yandanda, programlama alanındaki türkçe kaynak azlığını giderebilmek için bloglar yazmak.


  1. You could certainly see your skills in the work you write. The sector hopes for more passionate writers like you who aren’t afraid to mention how they believe. At all times go after your heart.

  2. I do not even know how I ended up here, but I thought this post was good. I don’t know who you are but certainly you’re going to a famous blogger if you aren’t already 😉 Cheers!

  3. I have recently started a blog, the information you provide on this website has helped me greatly. Thank you for all of your time & work.

  4. Good day! I simply want to give an enormous thumbs up for the great information you have right here on this post. I will likely be coming back to your blog for extra soon.

  5. Hi, i think that i saw you visited my weblog thus i came to “return the favor”.I am attempting to find things to improve my website!I suppose its ok to use a few of your ideas!!

  6. Hey, you used to write fantastic, but the last several posts have been kinda boringK I miss your super writings. Past few posts are just a little out of track! come on!

  7. Hello, Neat post. There’s an issue together with your web site in internet explorer, might test thisK IE nonetheless is the market chief and a huge component to folks will leave out your wonderful writing because of this problem.

  8. I’ll immediately grab your rss as I can’t find your e-mail subscription link or newsletter service. Do you’ve any? Please let me know in order that I could subscribe. Thanks.

  9. I beloved as much as you will obtain performed right here. The cartoon is tasteful, your authored material stylish. however, you command get bought an edginess over that you want be handing over the following. in poor health indubitably come further formerly once more since precisely the same just about a lot often inside of case you shield this increase.

  10. It’s in point of fact a great and helpful piece of information. I am glad that you simply shared this useful information with us. Please stay us informed like this. Thanks for sharing.

  11. Needed to write you one little remark to finally thank you once again just for the magnificent suggestions you have shown on this site. It is quite generous of you to make easily all most of us might have made available as an ebook in making some profit on their own, particularly considering that you could have done it in the event you wanted. These concepts additionally served like the easy way to fully grasp that other individuals have similar fervor just as my own to realize lots more in regard to this condition. I am certain there are thousands of more fun opportunities ahead for many who find out your blog post.

  12. you are really a good webmaster. The site loading speed is incredible. It seems that you are doing any unique trick. Furthermore, The contents are masterpiece. you have done a magnificent job on this topic!

  13. Having read this I thought it was very informative. I appreciate you taking the time and effort to put this article together. I once again find myself spending way to much time both reading and commenting. But so what, it was still worth it!

  14. hey there and thank you for your information – I have certainly picked up anything new from right here.
    I did however expertise some technical points using this website, since I experienced to reload
    the site lots of times previous to I could get it to load correctly.
    I had been wondering if your web hosting is OK? Not that I’m complaining, but slow loading instances times will often affect your placement in google and could damage your high quality score if ads and
    marketing with Adwords. Well I am adding this RSS to my e-mail and could
    look out for a lot more of your respective exciting content.
    Make sure you update this again soon.

  15. A person essentially lend a hand to make severely posts I’d state. That is the very first time I frequented your website page and thus far? I surprised with the research you made to make this particular put up amazing. Fantastic task!

  16. Hi, I think your site might be having browser compatibility issues. When I look at your website in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!

  17. CO2激光(CO2 laser / 二氧化碳激光)的波長是10600nm,照射到皮膚上會被皮膚的水份吸收,瞬間將皮膚有問題的組織氣化。CO2激光可以用來消除各種皮膚問題包括疣、癦、痣、脂溢性角化、粉刺和汗管瘤等。當治療後,您的皮膚需要5至10天時間復原。期間保持傷口清潔便可。優點:CO2激光所切割的深度比刮除術較深,亦較精準。可以處理較深層的皮膚問題,例如去除癦、油脂粒、肉粒、疣、珍珠疣、角質增生等。其復原亦較快,減少留下疤痕的機會。它最大的優點在於,能夠進一步減少激光治療過程當中的熱損傷反應,提升了激光治療的安全性,治療過程中幾乎沒有疼痛感

  18. Admiring the dedication you put into your site and in depth information you present. It’s good to come across a blog every once in a while that isn’t the same outdated rehashed information. Wonderful read! I’ve bookmarked your site and I’m adding your RSS feeds to my Google account.

  19. Thank you for the auspicious writeup. It in fact was once a entertainment account it. Look complex to far delivered agreeable from you! By the way, how could we keep up a correspondence?

  20. I am really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it’s rare to see a great blog like this one these days..

  21. Undeniably believe that which you stated. Your favourite reason appeared to be on the internet the simplest thing to remember of. I say to you, I certainly get annoyed at the same time as folks consider worries that they just don’t understand about. You managed to hit the nail upon the highest and defined out the whole thing with no need side effect , people could take a signal. Will likely be again to get more. Thank you

  22. Right here is the right site for anyone who hopes to understand this topic.
    You know so much its almost hard to argue with you (not that I personally would want to…HaHa).
    You certainly put a new spin on a topic that’s been discussed for decades.
    Wonderful stuff, just wonderful!

  23. Great items from you, man. I’ve be mindful your stuff previous to and you are simply extremely magnificent. I really like what you have got here, certainly like what you are saying and the way wherein you are saying it. You’re making it enjoyable and you continue to take care of to keep it smart. I can not wait to learn far more from you. This is really a tremendous site.

  24. Hiya, I’m really glad I’ve found this information. Nowadays bloggers publish just about gossips and web and this is really irritating. A good blog with exciting content, that is what I need. Thank you for keeping this web site, I’ll be visiting it. Do you do newsletters? Cant find it.

  25. I happen to be writing to let you be aware of of the nice discovery my wife’s girl went through reading through your blog. She figured out a wide variety of pieces, not to mention how it is like to possess a wonderful coaching mood to make certain people with ease know precisely chosen advanced subject matter. You truly exceeded visitors’ expectations. I appreciate you for displaying the effective, trusted, educational as well as cool thoughts on this topic to Janet.

  26. I am really enjoying the theme/design of your web site. Do you ever run into any web browser compatibility issues? A handful of my blog audience have complained about my blog not operating correctly in Explorer but looks great in Opera. Do you have any solutions to help fix this problem?

  27. I precisely needed to thank you so much again. I am not sure what I would’ve done without those thoughts shown by you about such a concern. It had been a intimidating circumstance in my circumstances, but observing a new professional avenue you treated that took me to weep for fulfillment. Now i’m thankful for this guidance and trust you know what a great job that you’re accomplishing teaching many others thru your websites. Most likely you have never got to know all of us.

  28. Thanks for every other excellent article. Where else may just anybody get that kind of information in such a perfect manner of writing? I’ve a presentation subsequent week, and I am at the look for such info.


Lütfen yorumunuzu giriniz
Buraya isminizi giriniz