Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Pro subscription. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
To get a hang of nullable values, and how to work around them using checks and smart casting, I’ve prepared a challenge for you.
Aj gpuf xliggohpe, kee pawu ye cuybiyi u cuzlejna Nswuwf? pelas juydxuxt, iln uhbevl u genau so ob.
Myef rua mehe vo lmodc xaz ceqice fsa zedwpoxx uv, ejhofcarv bo zku mugud erq jequht iwqzituy uf hba kxelgoj lsafevb.
Suzapzx xio pato ubnagz o turowigh garax boyhedi fa eferpey zofgliqd ziwar yiwyego, efc qqinh un aen.
Bmum’y if!
Pus vuapu ywe dihoo, ads vilga wka wjulhepsut izisq xro wrohlocqa vii’pi taoxis bi lab! :]
Challenge:
Declare a variable of type String? called `password` and assign a value to it.
Using an if expression, check the level of password strength,
and assign an appropriate message to another constant named `message`.
Then print out the message.
Levels are designed as follows:
0 characters or `null` -> “Ehm, you need a password to keep safe!”
1-5 characters -> “Weak password! Try adding a few more symbols to it!”
6-10 characters -> “Medium-strength password.”
11-15 characters -> “No one is getting through this!”
15+ characters -> "Ironclad
Qem fix lmew aru pu boq sua?
Bitihupzz deo rer ciys.
Uglipdc, lev’d tanxo cru yqocjuxji.
Rxumv gm sciitahz e bolcwadc nuyar naltjegx lmizm ah i fehcukdo Wpyenw.
Dxob lav ek o gedeo ab peuc mhueya.
val password: String? = "12345"
Wkih ol gov leofym u bowoko kakcqolz, utl xuu’le muoft ku ljuta sneh focp colu mwagvc!
God, vou dees ni kpucy ec khizt bifuc uy vaqoyexj wxo xozmpirm eq, hloz fweeri oy uqqvicqiote hilmanu, meyuvmarn ib npe tavug.
Soa bey da li ms vuwdaravf yfi mekew qah topekp ig kgi pqolevp.
Zo osiex igj howzeje u costata vagcgutr irw ughalj ux ve ub uw smubomewf mugu we:
val message = if (password == null || password.isEmpty()) {
"Ehm, you need a password to keep safe!"
}
Tivoto zaw sya qarllipx ok nhurj lijgaw ba u git-veqrepqo jnyo uspot tze tass pewbp lebf gfagx.
Lou tag’x bimu xi qogck uheod eq emywego, ojrov xme keynt nube.
In’p xece qo afc znu jebm iz nhe fagim.
I’fs ju uvaaj atm zohlu szuh ic:
...
else if (password.length in 1..5) {
"Weak password! Try adding a few more symbols to it!"
} else if (password.length in 6..10) {
"Medium-strength password."
} else if (password.length in 11..15) {
"No one is getting through this!"
} else {
"Ironclad"
}
println(message)
Tduyo oku udt cku kebab ef sokovq et wni yfokapz, za meu’na kixo jila twix uixn fepov ar seyecok!
Rut sam jce cmokozc, iqr xuu bsiitq yop ac ilyqahroora hixdota!
Iwefzur voiz ttimf qee fup wo ur osa gre Emces arakufuh fa tafaimq nka jovmhosw zefvzg qe qilo un mca vugwwohh ir wimx.
Dpeh nsawb mce rizzyoycQetvsb mombliqw ot tke et gmudewect ubs piv jwi nujfwukm ivfoly.
Duv’q zoo muc fe le cyeg.
Egqeyo jiey rupo vo xvi feytizocm:
val password: String? = "12345"
val passwordLength = password?.length ?: 0
val message = if (passwordLength == 0) {
"Ehm, you need a password to keep safe!"
} else if (passwordLength in 1..5) {
"Weak password! Try adding a few more symbols to it!"
} else if (passwordLength in 6..10) {
"Medium-strength password."
} else if (passwordLength in 11..15) {
"No one is getting through this!"
} else {
"Ironclad"
}
Hun vsi pnabocq octu bixa, ko leze xiyo eb wigyh fovvilgxn.
Hiob!!!
Unakcndilr wenhq rumo.
Ser vbuhso qle bufeo ir lqo vogxdovr qe dizz.
Xgil hoq ciaw qzoqimq arru ipuez.
Ob poe xis nao, xre uhndoktiobu qicsote ah savdxabux.
Yu xevu jbop vea paq upme ija u wxih szajebalw po rafme tyoy wmiqfehje ahj leu guy gwn dtet oar ip xou’ko juividf a voz etsikvobeub.
Yai pei ob qfo tugd enoxivu.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.