diff options
| author | Marti Bolivar <mbolivar@mit.edu> | 2010-12-03 20:18:00 -0500 |
|---|---|---|
| committer | Marti Bolivar <mbolivar@mit.edu> | 2010-12-03 20:18:00 -0500 |
| commit | 5ceac644e90c929e77f05d357d1d35d45e673fac (patch) | |
| tree | 18c76f6117942fa46391fbbd8bd24e2c759c4895 /docs/source/lang/enum.rst | |
| parent | e5b1e44a8ae8c593456f4b4734f05c9065f6f07b (diff) | |
| download | librambutan-5ceac644e90c929e77f05d357d1d35d45e673fac.tar.gz librambutan-5ceac644e90c929e77f05d357d1d35d45e673fac.zip | |
cleaning up previous commits.
note that addition of new files under docs/source/lang/api and
docs/source/lang/cpp which were just copies of files in
docs/source/lang/ imply that change history is lost to git.
Diffstat (limited to 'docs/source/lang/enum.rst')
| -rw-r--r-- | docs/source/lang/enum.rst | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/docs/source/lang/enum.rst b/docs/source/lang/enum.rst deleted file mode 100644 index ba82383..0000000 --- a/docs/source/lang/enum.rst +++ /dev/null @@ -1,53 +0,0 @@ -.. highlight:: cpp - -.. _lang-enum: - -``enum`` -======== - -The ``enum`` keyword is used to specify an enumeration type. An -enumeration type is a type whose values are taken from a specified, -fixed list of constant values. - -Example -------- - -Here's an example defining an enumeration type called ``weather``, -which has values ``HOT``, ``COMFY``, and ``COLD``:: - - enum weather {HOT, COMFY, COLD}; - -Once you've defined this type, you can create variables of type -``weather``, in the same way you would with an :ref:`int <lang-int>` -or a :ref:`long <lang-long>`:: - - // create a weather variable named theWeather, with value COMFY: - weather theWeather = COMFY; - -Enumeration types are useful within :ref:`switch statements -<lang-switchcase>`. If you know that an argument is of an enumeration -type, you can make ``case`` statements for all of that type's possible -values, so you know you won't miss anything:: - - void describeWeather(weather currentWeather) { - switch(currentWeather) { - case HOT: - SerialUSB.println("it's hot out"); - break; - case COMFY: - SerialUSB.println("it's nice today"); - break; - case COLD: - SerialUSB.println("it's freezing!"); - break; - } - } - -Such a ``switch`` statement would need no :ref:`default -<lang-switchcase-default>`, since we know that ``currentWeather`` must -be either ``HOT``, ``COMFY``, or ``COLD``. - -See Also --------- - -- :ref:`lang-switchcase` |
