id
stringlengths
16
145
text
stringlengths
1
179k
title
stringclasses
1 value
kotlin_ObservableProperty_delegates/7_168_0.txt
The command ` finnishScrabble2('Z') ` causes an error. The command ` finnishScrabble2.apply('Z') ` causes an error.
kotlin_ObservableProperty_delegates/7_170_0.txt
In the Scala API, the data type ` Map ` is defined a trait with multiple abstract methods: it specifies what all ` Map ` s can do without specifying how any ` Map ` s actually implement those things. ` HashMap ` , in turn, is a concrete class that implements the abstract methods of the ` Map ` trait using an imple...
kotlin_ObservableProperty_delegates/8_31_0.txt
Question 1 Once upon a time, there were two ` var ` variables named ` hansel ` and ` gretel ` , who had the same data type. With that in mind, let’s examine the following piece of code:
kotlin_ObservableProperty_delegates/8_62_0.txt
* A dictionary: given a word in Finnish, we want to be able to find the corresponding word in English. * A student register: we want to be able to search for students by their student ID number. * An address book: we want to be able to find the person object that details an individual whose name we know. * A...
kotlin_ObservableProperty_delegates/7_193_0.txt
Close Loading...
kotlin_ObservableProperty_delegates/8_143_0.txt
Now when we ` apply ` for a missing key, we get this default value. This is a nice way to use a ` Map ` . Hence this rule of thumb:
kotlin_ObservableProperty_delegates/7_110_0.txt
The ` get ` method takes a key as a parameter. Its return type is ` Option[TypeOfValuesInMap] ` .
kotlin_ObservableProperty_delegates/8836_34_0.txt
# type '_OneByteString' is not a subtype of type 'Map<String, dynamic>' #883 Closed
kotlin_ObservableProperty_delegates/8_125_0.txt
The nice thing about ` apply ` , compared to ` get ` , it gives you a plain result without an ` Option ` , so the return value is a little bit easier to work with. The not-nice-at-all thing about ` apply ` is that it causes a runtime error if you pass in a non-existent key, so you need to be extra careful when you ...
kotlin_ObservableProperty_delegates/8_18_0.txt
Functions can’t really return more than a single value, but we can work around that restriction so that it’s as if they could. One workaround is to return a collection of two elements, say, a ` Vector[Int] ` . This solution isn’t terrible, but it’s a bit clunky to index the collection for the actual return values:
kotlin_ObservableProperty_delegates/7_143_0.txt
### The default method ` apply ` (and its dangers) You’re already used to indexing collections with expressions like ` myCollection(index) ` , which Chapter 5.3 revealed to be shorthand for method calls like ` myCollection.apply(index) ` . As you learned then, ` apply ` is a sort of implicit “default method” fo...
kotlin_ObservableProperty_delegates/8_85_0.txt
It’s straightforward to implement a little Finnish-to-English dictionary as a ` Map ` . First, we’ll need to ` import ` the ` Map ` class that we intend to use:
kotlin_ObservableProperty_delegates/8836_104_0.txt
Sorry, something went wrong. Copy link
kotlin_ObservableProperty_delegates/7_135_0.txt
We call ` swap ` on every key–value pair. If you do something like this, watch out: the keys of a map are unique. If our mini-dictionary had contained multiple words that translate to the same English word, we would have lost information while swapping. (Try it.)
kotlin_ObservableProperty_delegates/7_90_0.txt
The ` map ` method is available on all sorts of collections, not just on ` Map ` s. ## But Before We Get to ` Map ` s: Key–Value Pairs
kotlin_ObservableProperty_delegates/showthread.php3_46_0.txt
## Re: map name does not name a type error > If the element symbol is convertable to an int, then you have a simple > c-style array indexed on the int that returns the required value. This will > potentially use memory that isn't actually used - but it will be quick. > Consider for values "A", "B", "C" - 14, 15, 16 a...
kotlin_ObservableProperty_delegates/8836_84_0.txt
mouryaavadhesh commented Mar 4, 2022 hey, any solution for that ?? it's still an issue for me | exception: type '_OneByteString' is not a subtype of type 'Map<String, dynamic>' | [device_info: OPPO_CPH2127_53a2372f1831d9ec_qcom] --- All reactions
kotlin_ObservableProperty_delegates/8_138_0.txt
You’ll find ` Society ` in module Miscellaneous. Add a ` yearOfDeath ` method to the class. The method should: * receive a member ID as a parameter; * return an ` Option[Int] ` that wraps the year of death of the member with the given ID; except that * if the member doesn’t exist or is not dead yet, the met...
kotlin_ObservableProperty_delegates/8_163_0.txt
The pedagogy of using O1Library for simple graphical programming (such as ` Pic ` ) is inspired by the textbooks How to Design Programs by Flatt, Felleisen, Findler, and Krishnamurthi and Picturing Programs by Stephen Bloch. The course platform A+ was originally created at Aalto’s LeTech research group as a stu...
kotlin_ObservableProperty_delegates/showthread.php3_15_0.txt
* * * 3. August 7th, 2019, 01:39 AM #3 Richard.J * View Profile * View Forum Posts Senior Member
kotlin_ObservableProperty_delegates/8836_41_0.txt
Response response = await _dio.get('user/info'); Map<String, dynamic> json = jsonDecode(jsonEncode(response.data)); additional info : platform i test on : android platform version : 8.0 dio version : 3.0.9 report rate : 5 % of the time only in release mode --- The text was updated success...
kotlin_ObservableProperty_delegates/7_33_0.txt
The command is invalid. ` hansel2 ` is assigned the value of ` gretel ` and ` gretel2 ` the value of ` hansel ` .
kotlin_ObservableProperty_delegates/8836_146_0.txt
Milestone No milestone
kotlin_ObservableProperty_delegates/8836_112_0.txt
maxzod commented Nov 21, 2022 still appearing on ` sentry.io ` console --- All reactions
kotlin_ObservableProperty_delegates/showthread.php3_28_0.txt
> Last edited by LMHmedchem; August 7th, 2019 at 10:24 AM . Reply With Quote
kotlin_ObservableProperty_delegates/8836_134_0.txt
Copy link Member
kotlin_ObservableProperty_delegates/showthread.php3_45_0.txt
England Posts 7,826
kotlin_ObservableProperty_delegates/7_24_0.txt
Here’s a familiar-looking way to access the members of a pair: var myPair = ("good thing", "another thing")myPair: (String, String) = (good thing,another thing) myPair(0)res2: String = good thing myPair(1)res3: String = another thing
kotlin_ObservableProperty_delegates/8_53_0.txt
You may assume that the vector contains at least one element. A detailed hint on which methods to use
kotlin_ObservableProperty_delegates/8836_21_0.txt
Search syntax tips # Provide feedback
kotlin_ObservableProperty_delegates/7_67_0.txt
* Tuples are always immutable in size and content. Collections come in both mutable and immutable varieties. * Tuples don’t have the familiar collection methods ( ` size ` , ` map ` , ` indexOf ` , etc.) and you can’t use a ` for ` loop to iterate over a tuple (without resorting to additional trickery).
kotlin_ObservableProperty_delegates/8836_49_0.txt
All reactions * 👍 5 reactions
kotlin_ObservableProperty_delegates/8_116_0.txt
If you do something like this, watch out: the keys of a map are unique. If our mini-dictionary had contained multiple words that translate to the same English word, we would have lost information while swapping. (Try it.) If you want a key to be associated with multiple values, you can pair the key with a collection t...
kotlin_ObservableProperty_delegates/showthread.php3_20_0.txt
4. August 7th, 2019, 03:12 AM #4 wolle * View Profile * View Forum Posts Member + Join Date
kotlin_ObservableProperty_delegates/ObservableProperty_2_0.txt
[ ](https://kotlinlang.org) [ v1.9.23 ](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23) * Solutions * [ Multiplatform ](/lp/mobile/) * [ Server-side ](/lp/server-side/) * [ Data science ](/docs/data-science-overview.html) * [ Android ](/docs/android-overview.html) * [ Docs ](/docs/home.h...
kotlin_ObservableProperty_delegates/7_97_0.txt
I’m starting to get my arrows all mixed up. More about the arrow
kotlin_ObservableProperty_delegates/showthread.php3_7_0.txt
May 2009 Location Boston Posts
kotlin_ObservableProperty_delegates/7_137_0.txt
When you use a map, you often need to be alert to the possibility that the key you’re looking for is not present. There are several alternative ways of dealing with that contingency. You already know that a ` Map ` ’s ` get ` method returns an ` Option ` , which is ` None ` in case the key wasn’t found:
kotlin_ObservableProperty_delegates/8_136_0.txt
class Society(val name: String) { private val members = Map[Int, Member]() def add(newMember: Member) = { this.members(newMember.id) = newMember } def getByID(memberID: Int) = this.members.get(memberID) } Each ` Society ` object has a name. It...
kotlin_ObservableProperty_delegates/8_55_0.txt
Alternatively, you could try using the ` sliding ` method introduced in Week 6’s ` drySpell ` assignment. A+ presents the exercise submission form here.
kotlin_ObservableProperty_delegates/8836_33_0.txt
Already on GitHub? Sign in to your account Jump to bottom
kotlin_ObservableProperty_delegates/8836_18_0.txt
* Topics * Trending * Collections * Pricing
kotlin_ObservableProperty_delegates/8_73_0.txt
A ` Map ` object — a map-that-is-a-collection — is a collection of keys and values; it stores a mapping from keys to values. The ` map ` method is available on all sorts of collections, not just on ` Map ` s.
kotlin_ObservableProperty_delegates/8836_56_0.txt
Sorry, something went wrong. Copy link
kotlin_ObservableProperty_delegates/8_12_0.txt
Questions Answered: Can a function return two values? How can I easily find an object that corresponds to another object (e.g., the English translation of a Finnish word)? What’s an easy and efficient way to find elements in a collection when I have a search key of some sort (e.g., to find a student object among many ...
kotlin_ObservableProperty_delegates/8836_45_0.txt
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions. --- All r...
kotlin_ObservableProperty_delegates/8836_48_0.txt
easazade commented Sep 4, 2020 this is still an issue. --- 👍 5 Asquare17, liuyiyuan, cromuelbarut, AntonyMN, and Kemorave reacted with thumbs up emoji
kotlin_ObservableProperty_delegates/8836_90_0.txt
subzero911 commented May 19, 2022 I have the similar issue ` type '_TwoByteString' is not a subtype of type 'Map<String, dynamic>'. Error thrown null. ` --- All reactions
kotlin_ObservableProperty_delegates/7_151_0.txt
The command ` finnishScrabble('Z') ` causes an error. The command ` finnishScrabble.apply('Z') ` causes an error.
kotlin_ObservableProperty_delegates/8_123_0.txt
### The default method ` apply ` (and its dangers) You’re already used to indexing collections with expressions like ` myCollection(index) ` , which Chapter 5.3 revealed to be shorthand for method calls like ` myCollection.apply(index) ` . As you learned then, ` apply ` is a sort of implicit “default method” fo...
kotlin_ObservableProperty_delegates/7_6_0.txt
* Change language * suomi * Language * suomi #### Course
kotlin_ObservableProperty_delegates/8_169_0.txt
An error occurred while sending the submission for grading. Make sure you're connected to the internet. If a submission was consumed, the submission will be automatically graded after the service is available again. Loading...
kotlin_ObservableProperty_delegates/7_181_0.txt
You aren’t required to give written feedback. Nevertheless, please do ask something, give feedback, or reflect on your learning! (However, the right place to ask urgent questions about programs that you’re currently working on isn’t this form but the lab sessions or Piazza. We can’t guarantee that anyone will even see ...
kotlin_ObservableProperty_delegates/7_18_0.txt
Functions can’t really return more than a single value, but we can work around that restriction so that it’s as if they could. One workaround is to return a collection of two elements, say, a ` Vector[Int] ` .
kotlin_ObservableProperty_delegates/7_159_0.txt
* return an ` Option[Int] ` that wraps the year of death of the member with the given ID; except that * if the member doesn’t exist or is not dead yet, the method should return ` None ` .
kotlin_ObservableProperty_delegates/8_41_0.txt
` partition ` also divides the elements of the original collection in two and returns a pair of collections: val (freezing, aboveFreezing) = temperatures.partition( _ < 0 )freezing: Vector[Int] = Vector(-1, -5, -1) aboveFreezing: Vector[Int] = Vector(3, 6, 3, 2)
kotlin_ObservableProperty_delegates/8_35_0.txt
None of the above. It’s not possible to know what happens without knowing the two original variables’ values. ### A pair as a parameter
kotlin_ObservableProperty_delegates/showthread.php3_25_0.txt
Join Date May 2009 Location
kotlin_ObservableProperty_delegates/7_194_0.txt
× ####
kotlin_ObservableProperty_delegates/8_159_0.txt
Thousands of students have given feedback that has contributed to this ebook’s design. Thank you! The ebook’s chapters, programming assignments, and weekly bulletins have been written in Finnish and translated into English by Juha Sorva.
kotlin_ObservableProperty_delegates/8_87_0.txt
We can create a ` Map ` object like this: val finnishToEnglish = Map("kissa" -> "cat", "laama" -> "llama", "tapiiri" -> "tapir", "koira" -> "puppy")finnishToEnglish: Map[String,String] = Map(koira -> puppy, tapiiri -> tapir, kissa -> cat, laama -> llama)
kotlin_ObservableProperty_delegates/8836_106_0.txt
edited +1, only happens in Release mode --- 👍 4 WiRight, yaro-melnychuk, wishtree-skaranje, and shaoting0730 reacted with thumbs up emoji
kotlin_ObservableProperty_delegates/showthread.php3_29_0.txt
* * * 6. August 7th, 2019, 11:32 AM #6 wolle * View Profile * View Forum Posts Member +
kotlin_ObservableProperty_delegates/8836_80_0.txt
Sorry, something went wrong. Copy link
kotlin_ObservableProperty_delegates/ObservableProperty_1_0.txt
[ ](https://kotlinlang.org) [ v1.9.23 ](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23) * Solutions * [ Multiplatform ](/lp/mobile/) * [ Server-side ](/lp/server-side/) * [ Data science ](/docs/data-science-overview.html) * [ Android ](/docs/android-overview.html) * [ Docs ](/docs/home.h...
kotlin_ObservableProperty_delegates/showthread.php3_1_0.txt
* Forum * New Posts * FAQ * Calendar * Forum Actions * Mark Forums Read * Quick Links * Today's Posts * View Site Leaders * What's New? * Advanced Search
kotlin_ObservableProperty_delegates/7_140_0.txt
On ` Option ` s, the ` getOrElse ` method essentially tells the ` Option ` object: “Give me the value you contain or, failing that, use this value instead.” The ` getOrElse ` method of a ` Map ` similarly tells the ` Map ` : “Give me the value that corresponds to this key or, failing that, use this value instead....
kotlin_ObservableProperty_delegates/showthread.php3_11_0.txt
2. August 7th, 2019, 12:54 AM #2 wolle * View Profile * View Forum Posts Member + Join Date
kotlin_ObservableProperty_delegates/8_24_0.txt
Here’s one way to access the members of a pair: var myPair = ("good thing", "another thing")myPair: (String, String) = (good thing,another thing) myPair._1res2: String = good thing myPair._2res3: String = another thing
kotlin_ObservableProperty_delegates/8_168_0.txt
« Chapter 8.3: Robots and Conditional Looping Course materials Week 9 » * Privacy Notice * Accessibility Statement * Support * Feedback * A+ v1.23.0
kotlin_ObservableProperty_delegates/8_100_0.txt
finnishToEnglish -= "laama"res28: Map[String, String] = Map(koira -> dog, tapiiri -> tapir, kissa -> cat, sika -> pig, hiiri -> mouse) There’s also a ` remove ` method that returns the removed value in an ` Option ` wrapper:
kotlin_ObservableProperty_delegates/8836_77_0.txt
+1 --- All reactions Sorry, something went wrong.
kotlin_ObservableProperty_delegates/8_157_0.txt
I’m unable to answer or don’t want to comment. Written comment or question:
kotlin_ObservableProperty_delegates/ObservableProperty_0_0.txt
[ ](https://kotlinlang.org) [ v1.9.23 ](https://github.com/JetBrains/kotlin/releases/tag/v1.9.23) * Solutions * [ Multiplatform ](/lp/mobile/) * [ Server-side ](/lp/server-side/) * [ Data science ](/docs/data-science-overview.html) * [ Android ](/docs/android-overview.html) * [ Docs ](/docs/home.h...
kotlin_ObservableProperty_delegates/8836_20_0.txt
Search Clear
kotlin_ObservableProperty_delegates/8_144_0.txt
* If there is a default value that makes sense for your ` Map ` , use ` withDefaultValue ` to define it. If you do, it’s both safe and convenient to fetch values with ` apply ` . * Otherwise, use ` get ` or ` getOrElse ` to access values. Question 1
kotlin_ObservableProperty_delegates/7_17_0.txt
It would be nice if we could also save the returned values for later use in two separate variables; say, ` min ` and ` s ` . ### Possible solutions
kotlin_ObservableProperty_delegates/7_26_0.txt
Another significant difference is that the size of a pair is known in advance. This attempt produces a compile-time error and thus cannot crash a program at runtime: nameAndShoeSize(2)-- Error: nameAndShoeSize(2) ^
kotlin_ObservableProperty_delegates/8836_47_0.txt
Author ###
kotlin_ObservableProperty_delegates/8_70_0.txt
A map contains key–value pairs* . When you use, say, a buffer, you look up elements by their positions in the collection; when you use a map, you instead look up values by their keys. You can use any objects as keys. Those objects form a set in the mathematical sense of the word; in practice, that means that all of ...
kotlin_ObservableProperty_delegates/7_82_0.txt
Third, What if the key is not found? For example: englishTranslation(searchTerms.indexOf("Mikki-Hiiri"))
kotlin_ObservableProperty_delegates/8_114_0.txt
val myPair = "key" -> "value"myPair: (String, String) = (key,value) myPair.swapres34: (String, String) = (value,key) Here’s the ` swap ` operation applied to an entire ` Map ` :
kotlin_ObservableProperty_delegates/8836_30_0.txt
Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Wiki * Security * Insights
kotlin_ObservableProperty_delegates/8836_9_0.txt
Plan and track work * Discussions
kotlin_ObservableProperty_delegates/8_26_0.txt
The most important difference between a pair and, say, a two-element vector is that a pair’s members can have different static types: val nameAndShoeSize = ("Juha", 43)nameAndShoeSize: (String, Int) = (Juha,43)
kotlin_ObservableProperty_delegates/8836_108_0.txt
Sorry, something went wrong. Copy link
kotlin_ObservableProperty_delegates/7_66_0.txt
Here are some of the technical differences between tuples and collections: * In a tuple, each member has a distinct static type. In a collection, the elements share a static type.
kotlin_ObservableProperty_delegates/8836_111_0.txt
Copy link ###
kotlin_ObservableProperty_delegates/8_30_0.txt
A+ presents the exercise submission form here. Here’s a variation on a question from Chapter 1.4
kotlin_ObservableProperty_delegates/showthread.php3_22_0.txt
## Re: map name does not name a type error > Well after I had realized that my Singleton approach was unnecessarily > complicated I would've changed to an ordinary global function instead like, > > Code: > > > #ifndef MY_CONSTANTS_ONCE > #define MY_CONSTANTS_ONCE > > #include <string> > ...
kotlin_ObservableProperty_delegates/8836_72_0.txt
I have the same problem too and it is in shared preferences when I use this line bool isFirstTime = Global.prefs?.getBool('isFirstTime') ?? "true"; And the error is type '_OneByteString' is not a subtype of type 'bool' Any solution ? --- All reactions Sorry, something went wrong.
kotlin_ObservableProperty_delegates/7_2_0.txt
Toggle navigation * Log in
kotlin_ObservableProperty_delegates/7_5_0.txt
* Home * Begin by enrolling in a course. * Log in * Skip course navigation * #### Language
kotlin_ObservableProperty_delegates/7_190_0.txt
This submission is identical to the previous submission . Are you sure you want to submit it? Cancel Submit
kotlin_ObservableProperty_delegates/7_78_0.txt
val index = searchTerms.indexOf("tapiiri")index: Int = 2 englishTranslation(index)res18: String = tapir englishTranslation(searchTerms.indexOf("koira"))res19: String = puppy We can also update the dictionary by replacing an element. The Finnish word “koira” is better translated as “dog” than...
kotlin_ObservableProperty_delegates/8836_11_0.txt
* All features * Documentation * GitHub Skills * Blog * Solutions
kotlin_ObservableProperty_delegates/8836_55_0.txt
easazade commented Sep 5, 2020 by clearing cache you mean the application cache? --- All reactions
kotlin_ObservableProperty_delegates/8_9_0.txt
Luet oppimateriaalin englanninkielistä versiota. Mainitsit kuitenkin taustakyselyssä osaavasi suomea. Siksi suosittelemme, että käytät suomenkielistä versiota , joka on testatumpi ja hieman laajempi ja muutenkin mukava. Suomenkielinen materiaali kyllä esittelee englanninkielisetkin termit. Myös suomenkielisessä mate...
kotlin_ObservableProperty_delegates/8_69_0.txt
The collections that we call “maps” have a number of alternative names. “Map” is perhaps the most common, but “dictionary” (or “dict”) and “associative array” are widely used, too. Let’s use a collection that stores both keys and values. A map ( hakurakenne ) is a tremendously useful and common collection type, and...
kotlin_ObservableProperty_delegates/8_137_0.txt
The ` Society ` object has methods for adding members and finding existing members by their ID. These methods have been implemented by calling the ` Map ` ’s methods. ### Mini-assignment: ` Map ` s and ` Option `