Instantly share code, notes, and snippets.

# TheMuellenator/constants.swift

Last active April 23, 2024 16:37
Show Gist options
• Save TheMuellenator/4bfc62a9f5226e10246fbb08e19bdea3 to your computer and use it in GitHub Desktop.
iOS repl.it - Constants Challenge Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 //Write your code here. // Solution let secondsInAnHour = 3600 // alternatively: // let secondsInAnHour: Int = 3600 // Note, constants can only be set once and cannot be assigned a new value. // The below does not work, because it is a constant and thus cannot be changed. // secondsInAnHour = 1337 //Don't change the code below. print(secondsInAnHour)

### alvarezac1 commented Oct 29, 2019

hey @TheMuellenator was this a trick question? Is it as simple of let secondsInAnHour = 3600?

I thought we had to select one of the seconds in the hour. Just double checking!

### dimlaitman commented Nov 17, 2019

hey @TheMuellenator was this a trick question? Is it as simple of let secondsInAnHour = 3600?

I thought we had to select one of the seconds in the hour. Just double checking!

Yes, very easy! Didn't expect so solution...

### Ritvik2021 commented Dec 16, 2019

WTH is the solution, it makes no sense...

"This does not work, because it is a constant and thus cannot be changed"??????

weren't we meant to declare it as a constant?

### artyom-ivanov commented Jan 11, 2020

Solution with type-checking

let secondsInAnHour: Int = 3600
print(secondsInAnHour)

### jihredoy commented Apr 15, 2020 • edited

hahaha Github trying to make my code wrong. that's why screenshot:

### JenniferQuesada commented Jun 4, 2020

I thought it had to be something a little bit more complicated, like with some sort of math equation LOL

### hailinhpro commented Jun 5, 2020 • edited

There are many ways to complete this challenge. I used this code below and passed:

let sencondInAnHour = Int(3600)

### krrish-cmd commented Jun 7, 2020

hahaha Github trying to make my code wrong. that's why screenshot:

hahaha Github trying to make my code wrong. that's why screenshot:

lol

### krrish-cmd commented Jun 7, 2020

please mullenator.can u please explain the question. i am not getting what is the question

### RakhimaN commented Jun 23, 2020

Hi! What if I write var instead of let?

### bhaveshtandel17 commented Sep 25, 2020

Hi! What if I write var instead of let?

It will work, But no mean to use var keywords for constants (as it was immutable value).

• Use var for variables
• Use let for constants

### NastasiaIOSdev commented Dec 19, 2020

func exercise() {

let secondsInAnHour: Int = 3600

//Don't change the code below.
print(secondsInAnHour)

}

### rgsgroup2005 commented Dec 28, 2020

LOL! Only here did I realize that I was wasting all this time adding minutes rather than seconds in the hour! 🤣🤦‍♂️

### brawler89 commented Mar 30, 2021

My solution:

let secondsInAnHour: Int = 60*60

//Don't change the code below.
print(secondsInAnHour)

### Magdalenaspace commented Sep 26, 2022

func exercise() {

let secondsInAnHour = 60 * 60

print(secondsInAnHour)

}

### Turevha commented Oct 5, 2022

This was a straight forward answer, I even looked for some tricks too

### josileudo commented Nov 5, 2022

var hour = 1;
var min = 60
var sec = 60

let secondsInAnHour = hour * min * sec;

print(secondsInAnHour);

### Denaag commented Jan 28, 2023

let secondsInAnHour = 3600

print(secondsInAnHour)

### eltonbrayner commented Jun 9, 2023

let secondsInAnHour = 60 * 60

print(secondsInAnHour)