Tutorialspoint

variable declaration

var varA = 42
print(varA)

sampleswiftprogram

/* My first program in Swift 4 */
var myString = "Hello, World!"
print(myString)

Ext.jsExt.tab.PanelContainer

<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" 
         rel = "stylesheet" />
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      
      <script type = "text/javascript">
         Ext.onReady(function () {
            Ext.create('Ext.tab.Panel', {
               renderTo: Ext.getBody(),
               height: 100,
               width: 200,
               
               items: [{
                  xtype: 'panel',
                  title: 'Tab One',
                  html: 'The first tab',
                  listeners: {
                     render: function() {
                        Ext.MessageBox.alert('Tab one', 'Tab One was clicked.');
                     }
                  }
               },{
                  // xtype for all Component configurations in a Container
                  title: 'Tab Two',
                  html: 'The second tab',
                  listeners: {
                     render: function() {
                        Ext.MessageBox.alert('Tab two', 'Tab Two was clicked.');
                     }
                  }
               }]
            });
         });
      </script>
   </head>
   
   <body>
   </body>
</html>

Ext.jsExt.tab.PanelContainer

<!DOCTYPE html>
<html>
   <head>
      <link href = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" 
         rel = "stylesheet" />
      <script type = "text/javascript" 
         src = "https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      
      <script type = "text/javascript">
         Ext.onReady(function () {
            Ext.create('Ext.tab.Panel', {
               renderTo: Ext.getBody(),
               height: 100,
               width: 200,
               
               items: [{
                  xtype: 'panel',
                  title: 'Tab One',
                  html: 'The first tab',
                  listeners: {
                     render: function() {
                        Ext.MessageBox.alert('Tab one', 'Tab One was clicked.');
                     }
                  }
               },{
                  // xtype for all Component configurations in a Container
                  title: 'Tab Two',
                  html: 'The second tab',
                  listeners: {
                     render: function() {
                        Ext.MessageBox.alert('Tab two', 'Tab Two was clicked.');
                     }
                  }
               }]
            });
         });
      </script>
   </head>
   
   <body>
   </body>
</html>

extjssampleprogram

<!DOCTYPE html>
<html>
   <head>
      <link href="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/theme-classic/resources/theme-classic-all.css" rel="stylesheet" />
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/ext-all.js"></script>
      <script type="text/javascript">
         Ext.onReady(function() {
         Ext.create('Ext.Panel', {
            renderTo: 'helloWorldPanel',
            height: 100,
            width: 200,
            title: 'Hello world',
            html: 'First Ext JS Hello World Program'
            });
         });
      </script>
   </head>
   <body>
      <div id="helloWorldPanel"></div>
   </body>
</html>

type inference

// varA is inferred to be of type Int
var varA = 42
print(varA)

// varB is inferred to be of type Double
var varB = 3.14159
print(varB)

// varC is also inferred to be of type Double
var varC = 3 + 0.14159
print(varC)

type safety

var varA = 42
varA = "This is hello"
print(varA)

typealiases

typealias Feet = Int
var distance: Feet = 100
print(distance)

type

typealias Feet = Int
var distance: Feet = 100
print(distance)

sample

import Foundation
import Glibc
 
let player = ["rock", "paper", "scissors", "lizard", "spock"]
 
srandom(UInt32(NSDate().timeIntervalSince1970))
for count in 1...3 {
    print(count)
}
 
print(player[random() % player.count]);

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.