Transcript from the "Strings" Lesson
[00:00:37] Plus is only for addition. Plus, plus is for combining strings. We can use this plus, plus back in our pluralized function from earlier when we had the quantity and the singular and the plural. We can use this to make it so that it's going to display the number in addition to the singular or a plural.
[00:00:56] So instead of just saying leaf or leaves, this version is going to return five leaves or one leaf. Now this isn't quite right yet because as I said previously plus, plus is for combining two strings. But quantity here is actually not a string, it's a number. So this part will work over here where we have a space plus, plus a string cuz those are both strings.
[00:01:46] So there's a String.fromInt. There's a String.from float. There's other ways to convert different values to different types, but in our case quantity should be an integer. So we're gonna use String.fromInt. Also worth noting that you don't need any parenthesis to disambiguate here. Because the plus, plus actually implicitly groups things on either side of it.
[00:02:06] So everything to the left of this plus, plus is gonna be one expression. Everything to the right of it is gonna be another expression. The same is true of this other plus, plus. Everything to the left of it is gonna be one expression, and everything to the right is gonna be another.
[00:02:19] So anytime you see in-fix operators such as plus, plus, or the normal arithmetic ones like plus, minus, divided by and such. You can imagine that each of them implicitly creates parenthesis around everything to left and then everything to the right. So this whole thing is one expression that's going to evaluate to a string.