Posted to tcl by mookie at Fri Sep 27 22:51:12 GMT 2024view raw

  1. if you have a switch within a switch and use the character % within the line comment ";#" -- it breaks, without it doesn't
  2. ------
  3. Without %
  4. set animal dog
  5. switch $animal {
  6. dog {
  7. set animal2 cat
  8. switch $animal2 {
  9. cat {
  10. puts "Meow"
  11. }
  12. default {
  13. puts "Moo"
  14. } ;# end case default
  15. } ;# end switch animal 2
  16. puts "bark!"
  17. } ;# end case dog
  18. } ;# end switch "animal"
  19. works as expected.
  20. > Meow
  21. bark!
  22. ----
  23. set animal dog
  24. switch $animal {
  25. dog {
  26. set animal2 cat
  27. switch $animal2 {
  28. cat {
  29. puts "Meow"
  30. }
  31. default {
  32. puts "Moo"
  33. } ;# end case default
  34. } ;# end switch animal 2
  35. puts "bark!"
  36. } ;# end case dog %
  37. } ;# end switch "animal"
  38. > throws: extra switch pattern with no body -- is this normal?

AltStyle によって変換されたページ (->オリジナル) /