• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

KennethJackson.Tech

Multimedia Production in Amarillo, Texas

  • Home
  • IT Services
    • Web
  • Music
    • Woodshed
  • Video
  • About
  • Contact
You are here: Home / Work / Swift / Intermediate Swift – Chapter 2.1 Strings

Intermediate Swift – Chapter 2.1 Strings

November 4, 2018 by Kenneth Jackson Leave a Comment

import UIKit

let joke = """
    Q: Why did the chicken cross the road?
    A: To get to the other side!
    """

print(joke)

let greeting = "It is traditional in programming to print \"Hello World\"."

print(greeting)

var myString = ""

if myString.isEmpty {
    print("The string is empty.")
}

myString

let string1 = "Hello"
let string2 = ", world!"
let myString1 = string1 + string2

print(myString1)

var myString2 = "Hello"
myString2 = myString2 + ", world!"
myString2 += " Hello!"

print(myString2)


//String Interpolation

let name = "Kenneth"
let age = 53
print("\(name) is \(age) years old.") // Kenneth is 53 years old.

let a = 4
let b = 5
print("If a is \(a) and b is \(b), then a + b equals \(a+b)")

//String Equality and Comparison

let month = "January"
let otheMonth = "January"

let lowercasedMonth = "january"

if month == otheMonth {
    print("They are he same")
}

if month != lowercasedMonth {
    print("They are not the same.")
}

let name1 = "Johnny Appleseed"
if name1.lowercased() == "joHnny aPPleseeD".lowercased() {
    print("The two names are equal.")
}

let greeting1 = "Hello, world!"

print(greeting1.hasPrefix("Hello"))
print(greeting1.hasSuffix("world!"))
print(greeting1.hasSuffix("World!"))

let greeting2 = "Hi Jancy, my name is Kenneth."

    if greeting2.contains("my name is") {
        
        print("Making an introduction")
}

//Counting characters
let count = name.count
print(count)

let newPassword = "1234"

if newPassword.count < 8 {
    print("The password is too short. Passwords must have at least 8 characters.")
}

//Switch Statements

let someCharacter: Character = "e"
switch someCharacter {
case "a", "e", "i", "o", "u":
    print("\(someCharacter) is a vowel")
default:
    print("\(someCharacter) is not a vowel")
}

Share this:

  • Share
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on WhatsApp (Opens in new window) WhatsApp

Filed Under: Swift Tagged With: Amarillo, Strings, Swift 4.2, Texas, X-Code 10

Leave a ReplyCancel reply

  • Facebook
  • GitHub
  • Twitter
  • YouTube

Kenneth Jackson

(806) 374-2323
Please leave a voice or text message.

Contact Kenneth

Recent Posts: KennethJackson.Tech

Behringer – 297 Dual Portamento and CV Utilities – Notes

Yamaha – MX-88 – Synthesizer Notes

Isao Tomita – Artist Notes

Ableton Live File Types

Effects Design – Jon Dattorro – Notes

Categories

  • Design
  • Music
    • Ableton Live
    • Audio Effects
    • Gig Log
    • Synthesizers
      • DIY
      • Electronic Percussion
      • Eurorack
  • Stuff
    • Galleries
    • Latest News
    • One More Thing
  • Work
    • Client Work
    • Made In Amarillo
    • NGINX
    • Swift
    • Video
    • Web Development
      • Pay-Per-Click (PPC)
      • Search Engine Optimization (SEO)
      • WooCommerce

What can I Say? I like Tag Clouds.

#Wordpress Ableton Amarillo Analog Behringer Brody Blue Cowtown Opry Buckaroos Dana Hubbard DIY Electronic Drums Electrosmith Emily George Erica Synths Eurorack Facebook Google Hi-Hat Hilary Marie Presents Insufficient Funds Jazz Kayla Richardson Keitha Jones Kenneth Jackson Kick Drum Live Music Micah Bynum Michael D Coon Moog Music at Wellington Square Courtyard Pay-Per-Click PHP Polk Street Jazz PPC Reverb Rien and Mindi Snaps For Sinners Snare Drum Songwriters in the Round Starlight Canyon Bed and Breakfast Support Local Music Swift 4.2 Tennessee Tuckness & Friends Texas The Fwoops Yamaha
  • Facebook
  • Twitter
  • YouTube
  • GitHub
  • Discord
  • Contact Me
  • Payments
  • Privacy Policy

Copyright © Kenneth Jackson

Designed by Kenneth Jackson in Amarillo, Texas

Powered by WPplaces