Show me how can we use array comprehension to declare a dart list of 6 doubles, where…
Jump to turn (8)
- 1Show me how can we use array comprehension to declare a dart list of 6 doubles,
- 2Refactor it a bit so it calls function randominrange taking low and high bounds
- 3Now let's use our custom pseudo random implementation for randominrange. Note we
- 4Great, now inline that pseudo random class into the function randominrange, to g
- 5Now inline nextInt method in our randominrange as it is used only once
- 6Now make so the high bounds is not inclusive
- 7Is hashcode function consistent through a string on multiple platforms and launc
- 8I mean, myseed seed must generate similar number across Linux and Android each l
- User
Show me how can we use array comprehension to declare a dart list of 6 doubles, where the first one is 100 and the next 5 are a hardcoded random number from 3 to 11 times the previous value
- Assistantcode
import 'dart:math'; main() { var first = 100; var doubles = [first, ...[for (var i = 0; i < 5; i++) (first *= Random().nextInt(9) + 3)]]; print(doubles); // e.g. [100, 600, 3000, 66000, 1848000, 92160000] }Explanation:
var first = 100;initializes the first double with the value 100.