![]() a better way to do the same code snippet in a more readable and modular way, is to use a " SwitchCase" operator : Map> caseBlocks = new HashMap(2) ĬaseBlocks.put(1, ( integer) -> "First Odd Number : " + integer) ĬaseBlocks.put(2, ( integer) -> "First Even Number : " + integer) īoth code snippets do the same thing, but the main difference is the "readability", the second snippet reduced the Control Coupling between the Rx-Java stream and the outside world. A switch statement is another useful way to control the flow of program which is mostly used in those cases where we need our program to act on a single. Of course this sample is just for clarification, it is not about even and odd numbers. try do this to get selected button: int radioButtonID radioButtonGroup.getCheckedRadioButtonId () View radioButton radioButtonGroup.findViewById (radioButtonID) int idx radioButtonGroup. ![]() Return Observable.just( "First Even Number : " + integer) Return Observable.just( "First Odd Number : " + integer) a similar case to this is as follows : List list = Arrays.asList( 1, 2, 3, 4) ![]() Asking for help, clarification, or responding to other answers. One thing that we miss in Reactive Extensions (Rx.) is the flow control operators, if we need to do different behaviors bases on the emitted items, we have to make those ugly If-Else or Switch-Case blocks inside a flatMap() or whatever operator. Thanks for contributing an answer to Stack Overflow Please be sure to answer the question.Provide details and share your research But avoid. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |