switch case or if-elseif-else
3 ビュー (過去 30 日間)
古いコメントを表示
정효 김
2020 年 7 月 14 日
回答済み: Sai Sri Harsha Vallabhuni
2020 年 7 月 14 日
Hi guys. I was doing my assignment (Sierpenski triangle) and i solved it in two ways. switch case ans if-elseif-else. Which one do you think is more logical( less error)?
0 件のコメント
採用された回答
Sai Sri Harsha Vallabhuni
2020 年 7 月 14 日
In general, using a switch case gives better readability to the code. But, in your case, there isn't much difference as there are only three cases.
Coming to the more logical(less error), as both implement the same thing, there is no one better than the other in terms of logic.
Hope this helps.
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!