Swift: Switch and default case

This entry is part 27 of 41 in the series Swift

As in any other programming languages, the default case will be called when none of the cases are matched.

var num = 100
switch num {
case 10:
    print("=10")
case 20:
    print("=20")
case 30:
    print("=30")
case 40:
    print("=40")
default:
    print("None of the above")
}

swift

Java: Switch statement

This entry is part 13 of 54 in the series Learn Java

The switch statement checks for equality between an integer and a series of case labels.

It then executes the matching case.

The statement can contain any number of cases and may end with a default label for handling all other cases.

package javaapplication12;

public class JavaApplication12 {

    public static void main(String[] args) {

        int y = 1;

        switch (y) {
            case 0:
                System.out.println(y + " is Zero");
                break;
            case 1:
                System.out.println(y + " is One");
                break;
            default:
                System.out.println(y + " is something else");
        }
    }
}

switch

jQuery UI & Effects: Switch class

This entry is part 6 of 10 in the series jQuery UI Effects

jQuery UI Effects – switchClass Demo

Add and remove class(es) to elements while animating with changes in style.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Effects - switchClass Demo</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.9.1.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <style>
        .toggler {
            width: 500px;
            height: 200px;
            position: relative;
        }

        #button {
            padding: .5em 1em;
            text-decoration: none;
        }

        #effect {
            position: relative;
        }

        .newClass {
            width: 240px;
            padding: 1em;
            letter-spacing: 0;
            font-size: 1.2em;
            margin: 0;
        }

        .anotherNewClass {
            text-indent: 40px;
            letter-spacing: .4em;
            width: 410px;
            height: 100px;
            padding: 30px;
            margin: 10px;
            font-size: 1.6em;
        }
    </style>
    <script>
        $(function () {
            $('#button').click(function () {
                $('.newClass').switchClass('newClass', 'anotherNewClass', 1000);
                $('.anotherNewClass').switchClass('anotherNewClass', 'newClass', 1000);
                return false;
            });
        });
    </script>
</head>
<body>

<div class='toggler'>
    <div id='effect' class='newClass ui-corner-all'>
        Sorry that I have confused you.  I am switching in and out of a class.
    </div>
</div>
<a href='#' id='button' class='ui-state-default ui-corner-all'>Run Effect</a>

</body>
</html>
Try The Code

jQuery Mobile: Flip toggle switch

This entry is part 70 of 73 in the series jQuery Mobile

We look at how to build flip toggle switches.  

Flip toggle switches are useful for users to set the App settings, especially if you want to allow users to turn on or off certain features.

<!DOCTYPE html>
<html>
<head>
    <link href='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.css' rel='stylesheet'/>
    <script src='http://code.jquery.com/jquery-1.10.2.min.js'></script>
    <script src='http://code.jquery.com/mobile/1.4.1/jquery.mobile-1.4.1.min.js'></script>
    <title>Upwhere</title>
</head>
<body>
<div data-role='page'>
    <div data-role='header' data-theme='b'>
        <h1>Flip Toggle Switch</h1>
    </div>

    <div data-role='content'>
        <form>
            <label for='flip1'>Flip toggle switch:</label>
            <select id='flip1' name='flip1' data-role='slider'>
                <option value='off'>Off</option>
                <option value='on'>On</option>
            </select>
        </form>
    </div>
    <div data-role='content'>
        <form>
            <label for='flip2'>Flip toggle switch with theme:</label>
            <select name='flip2' id='flip2' data-role='slider' data-track-theme='b' data-theme='b'>
                <option value='off'>Off</option>
                <option value='on'>On</option>
            </select>
        </form>
    </div>
    <div data-role='content'>
        <form>
            <label for='flip3'>Mini flip toggle switch:</label>
            <select name='flip3' id='flip3' data-role='slider' data-mini='true'>
                <option value='off'>Off</option>
                <option value='on'>On</option>
            </select>
        </form>
    </div>

    <div data-role='footer' data-position='fixed'>
        <h4 style='text-align:center;'>I'm the footer</h4>
    </div>
</div>

</body>
</html>
Try The Code