Skip to main content
Bluvy Tube
Press Esc to exit fullscreen
Volume m
/
i
Theater mode 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. 🧵

Keyboard shortcuts

Space K
Play / pause
← →
Back / forward 5 s
J L
Back / forward 10 s
0–9
Jump to 0%–90% of the video
Home End
Start / end
, .
Previous / next frame (while paused)
< >
Slower / faster
↑ ↓
Volume
M
Mute / unmute
C
Captions
F
Fullscreen
I
Picture-in-picture
T
Theater mode
?
Show this help

🤯 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

Subscribe
0 views Published on 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 comment
?
🛡️ 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.
View original post on Bluesky
Link copied to clipboard

Sign in

Time to take a break

You've been watching videos for 30 minutes straight: give yourself 5 minutes away from the screen. Stand up, stretch, grab a glass of water… Your videos will be right here when you're back.