Kotlin For Beginners: References, Immutability (Const and Val), Properties, Variables, Data Classes (Skillshare)

Offered by Skillshare,
Kotlin For Beginners: References, Immutability (Const and Val), Properties, Variables, Data Classes (Skillshare)

In this short class, you will learn the fundamentals of how to represent information virtually in a Kotlin program. About half of what we do as programmers is design data structures to represent real world information virtually, and it turns out that there are good and bad ways to do this! One of the most important takeaways of this class, is that it is critically important to separate things which change (mutable) from things which don't change (immutable).

Topics include:

  • How references work with the JVM (simplified for beginners)
  • The problem of Shared Mutable State (this is bad)
  • How to avoid Shared Mutable State by introducing Immutability (const val and val properties) to your code
  • How and when it makes sense to use var references
  • How to make classes, and the data class construct

As discussed in this class, one of the most difficult technical challenges which programmers face, is dealing with Shared Mutable State (Shared change-able data). Our first defense against such problems, is to work with Immutable Data as often as possible.
Using either the try.kotlinlang.org online IDE, or your own preferred IDE, write a simple program which has:

  • A data class of some kind with at least two val properties, such as a "User" data class
  • A main function which serves as the entry point of the program's execution

Instructions:

  1. Create a val reference of the same type as your data class (i.e. instantiate your data class)
  2. Create a second val reference from the first val reference, using the copy() function (this function comes from the data class keyword).
  3. Change at least one of the properties in this new val reference, by using default arguments within the copy() function.

The purpose of this small project is to get you used to working with immutable data and vals. At first it can appear impossible to make a working program using data classes with only val references, but by using the copy function, we can create new immutable copies based on old data, mutating only the properties we wish to!

Go to Class
MOOC List is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Related Courses

How To Create A Web Hosting Business With Wordress - WHMCS Tutorial (Skillshare) Skillshare
Skillshare

How To Create A Web Hosting Business With Wordress - WHMCS Tutorial (Skillshare)

Welcome! In This Wordpress Tutorial, I Will Show you How to use the WHMCS App to create your own web hosting business from scratch! The WHMCS platform is an automated platform that basically allows your to create your own web hosting company. People can come to your wordpress website, purchase a domain and hosting and also install wordpress. Many companies use this same platform like namehero.com and a2hosting.

Self Paced
Self-Paced
Web Design Essentials: Creating Marketing Homepages That Drive Results  (Skillshare) Skillshare
Skillshare

Web Design Essentials: Creating Marketing Homepages That Drive Results (Skillshare)

Design websites that drive results! In this 60-minute class, join Dennis Field — a designer and product evangelist for web prototyping leader InVision — as he shares how to refine your creative process, capitalize on feedback, and use best practices to design a marketing site that leads to conversions for your company. This class is perfect for freelance website and product designers, small web design teams, and everyone who wants to increase the effectiveness of their web design.

Self Paced
Self-Paced
How To Make A Wordpress Website 2018 - Divi Theme Tutorial (Skillshare) Skillshare
Skillshare

How To Make A Wordpress Website 2018 - Divi Theme Tutorial (Skillshare)

Why Take This AMAZING Course? I am a highly rated instructor on udemy. I have over 400,000 views a month on tutorials with positive reviews! Use The #1 Selling Theme for Wordpress On The PLANET. I Have Helped Teach And Create Over 500 Wordpress Websites! Get a Modern And Amazing Look For Your Website That Will Impress! Learn From A Professional Who Creates Websites For a Living with over 6,000 Visits! THE MOST UPDATE AND MODERN TUTORIAL. Dont Settle For Outdated Content!; Get A fully Responsive Website And Mobile Responsive; Over 15,000,000 Minutes Watched. Over 4 Million Views. In 180 Countries.

Self Paced
Self-Paced
HTML5 for Web Development (HTML5 for Beginners) (Skillshare) Skillshare
Skillshare

HTML5 for Web Development (HTML5 for Beginners) (Skillshare)

HTML is a hypertext markup language. It is the most important building block of any website on the internet. HTML is used to describe the content of the website. In this class, I will teach you everything you need to know about HTML and HTML5 (the newest version). I try to go directly to the point and teach by example.

Self Paced
Self-Paced
How To Make A Wordpress Website - Simple For Beginners (Skillshare) Skillshare
Skillshare

How To Make A Wordpress Website - Simple For Beginners (Skillshare)

Why Take This AMAZING Course? Learn how to use the #1 Best selling Wordpress Theme In The World. Master WORDPRESS and the Brizy Page Builder. Complete Beginners Guide I Am A TOP 10% RATED INSTRUCTOR on Udemy and Youtube. Find out Why!! Get a Modern And Amazing Look For Your Website That Will Impress! Learn From A Professional Who Creates Websites For a Living with over 500,000 Monthly Visits! THE MOST UPDATE AND MODERN TUTORIAL. Dont Settle For Outdated Content! Get A fully Responsive Website And Mobile Responsive

Self Paced
Self-Paced
Create a website with your own simple, custom CMS using HTML, CSS, JavaScript, Django, & Python! (Skillshare) Skillshare
Skillshare

Create a website with your own simple, custom CMS using HTML, CSS, JavaScript, Django, & Python! (Skillshare)

In the next few videos, I'm going to teach you how to create a completely custom, CMS-driven website from scratch using a Job Listing website as an example. *This is a step by step tutorial with explanations along the way. This class is mainly going to be for designers who have some HTML, CSS, and JavaScript experience, who are maybe tired of manually entering data for portfolio pages and want to create a more efficient solution.

Self Paced
Self-Paced
How To Make A Real Estate Website With Wordpress 2017 (Skillshare) Skillshare
Skillshare

How To Make A Real Estate Website With Wordpress 2017 (Skillshare)

n this video, I will teach you how to make a fully responsive real estate wordpress website. This wordpress tutorial will help real estate agents, realtors, or property managers create a fully functional real estate wordpress website. The theme i use in this tutorial is the agentpress pro theme created by studiopress. Trust me, i spent about 1 month researching real estate wordpress themes and this was by far the best real estate websites. The theme is very easy to use and very responsive on the mobile devices.

Self Paced
Self-Paced
ES6 JavaScript Classes the Easy Way (Skillshare) Skillshare
Skillshare

ES6 JavaScript Classes the Easy Way (Skillshare)

In 2015, the JavaScript programming language got a major facelift with many improvements to the syntax and tons of new features. This new version is known as ES6, or ES2015, and each year since an updated version has been released. ES6 Classes, as well as instance and static methods, are vitally important to know and understand because so many projects and companies are migrating to the newest version of JavaScript. Many Front End libraries, such as React, rely heavily on the new Class syntax.

Self Paced
Self-Paced
WordPress for Beginners - Understand WordPress Quickly (Skillshare) Skillshare
Skillshare

WordPress for Beginners - Understand WordPress Quickly (Skillshare)

Learn how to work with WordPress and develop a website using AIT WordPress Themes. No coding or experience required. This class presents the basics of working with WordPress and offers practical screencast tutorials to teach you how to use our themes when building a new website. In short videos, you can find answers to FAQs that beginners most often encounter when getting familiar with WordPress. The course contains more than one hour of video tutorials.

Self Paced
Self-Paced