Passer au contenu principal
Bluvy Tube
Appuyez sur Échap pour quitter le plein écran
Volume m
/
i
Mode Cinéma t
f
/
🤯 1 << channel - 1 in Swift is not 1 << (channel - 1). ⚡ Shifts bind tighter than subtraction. 🔢 Channel 3: (1 << 3) - 1 = 7 → 0b111 💥 Three channels switched on instead of one. ✅ Fix: 1 << (channel - 1) = 4 → only bit 2. 😬 And channel 9? 511 needs 9 bits. UInt8 has 8. Fatal error at runtime. 🧵

Raccourcis clavier

Espace K
Lecture / pause
← →
Reculer / avancer de 5 s
J L
Reculer / avancer de 10 s
0–9
Aller à 0 %–90 % de la vidéo
Home End
Début / fin
, .
Image précédente / suivante (en pause)
< >
Ralentir / accélérer
↑ ↓
Volume
M
Couper / rétablir le son
C
Sous-titres
F
Plein écran
I
Image dans l’image
T
Mode cinéma
?
Afficher cette aide

🤯 1 << channel - 1 in Swift is not 1 << (channel - 1). ⚡ Shifts bind tighter than subtraction. 🔢 Channel 3: (1 << 3) - 1 = 7 → 0b111 💥 Three channels switched on instead of one. ✅ Fix: 1 << (channel - 1) = 4 → only bit 2. 😬 And channel 9? 511 needs 9 bits. UInt8 has 8. Fatal error at runtime. 🧵

Cane Allesta

Cane Allesta

@caneallesta.bsky.social

S'abonner
0 vue Publié le 24/11/2026 04:29 1:28
🤯 1 << channel - 1 in Swift is not 1 << (channel - 1). ⚡ Shifts bind tighter than subtraction. 🔢 Channel 3: (1 << 3) - 1 = 7 → 0b111 💥 Three channels switched on instead of one. ✅ Fix: 1 << (channel - 1) = 4 → only bit 2. 😬 And channel 9? 511 needs 9 bits. UInt8 has 8. Fatal error at runtime. 🧵
1 commentaire
?
🛡️ Guard it: 1...8 contains channel ? mask : 0

🎯 Rule: bitwise + arithmetic in one expression → parentheses. Always.

#Swift #iOSDev

🎓 Want to learn more? Check Swift Programming for Beginners: Learn Swift from Zero👇
www.udemy.com/course/swift...
Swift Programming for Beginners: Learn Swift from Zero
Learn Swift step by step: syntax, types, operators, control flow, optionals and collections, with projects and quizzes.
Voir le post d'origine sur Bluesky
Lien copié dans le presse-papier

Connexion

Il est temps de faire une pause

Ça fait 30 minutes que vous enchaînez les vidéos : accordez-vous 5 minutes loin de l'écran. Levez-vous, étirez-vous, buvez un verre d'eau… Les vidéos vous attendront ici.