This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
void main() { | |
var controller = StreamController<num>(); | |
// Create StreamTransformer with transformer closure | |
var streamTransformer = StreamTransformer<num, num>.fromHandlers( | |
handleData: (num data, EventSink sink) { | |
sink.add(data * 2); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
//this is the stream generated above | |
Stream<int> createNumberStream(int last) async* { | |
for (int i=1; i<= last; i++) { | |
yield i; //to be able to send spaced out events | |
} | |
} | |
main() async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
//this is the stream generated above | |
Stream<int> createNumberStream(int last) async* { | |
for (int i=1; i<= last; i++) { | |
yield i; //to be able to send spaced out events | |
} | |
} | |
main() async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
//this is the stream generated above | |
Stream<int> createNumberStream(int last) async* { | |
for (int i=1; i<= last; i++) { | |
yield i; //to be able to send spaced out events | |
} | |
} | |
main() async { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
Stream<int> createNumberStream(int last) async* { | |
for(int i=1; i <= last; i++) { | |
yield i; | |
} | |
} | |
main() async { | |
var stream = createNumberStream(5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val kotlinStudent = KotlinStudent(1, "Aung Aung", "Hledan") | |
val kotlinStudentNew = kotlinStudent.copy(address = "Pazuntaung") | |
println(kotlinStudent) | |
println(kotlinStudentNew) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class KotlinStudent(val id: Int, val name: String, val address: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Student { | |
private int id; | |
private String name; | |
private String address; | |
public Student(int id, String name, String address) { | |
this.id = id; | |
this.name = name; | |
this.address = address; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package thiha | |
import kotlin.text.StringBuilder | |
fun main(args: Array<String>) { | |
val x = 45 | |
if (x.isEven()) println("$x is even") else println("$x is odd") | |
val days = arrayOf("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat") | |
println(days.combineAll()) | |
val y = 44 | |
if (y.isEven()) println("$y is even") else println("$y is odd") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
Stream<int> createNumberStream(int last) async* { | |
for (var i = 0; i < last; i++) { | |
if(i==5) { | |
throw new Exception( | |
"Demo Exception when accessing 5th number" | |
); | |
} |