Skip to content

Commit e697162

Browse files
Ternary conditional operators (#952)
## Changes Minor change which converts some variable setting into ternary operations to help simplify the code. ## Checks By submitting your pull request for review, you agree to the following: - [X] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [X] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [X] To the best of my knowledge, all proposed changes are accurate. ---------
1 parent eaddbfe commit e697162

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

content/en-us/sound/objects.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,7 @@ sound:Play()
234234
-- Start checking if emitter should be enabled
235235
RunService.Heartbeat:Connect(function()
236236
-- Enable the emitter within a time range of the audio; otherwise disable it
237-
if sound.TimePosition >= 5 and sound.TimePosition < 20 then
238-
emitter.Enabled = true
239-
else
240-
emitter.Enabled = false
241-
end
237+
emitter.Enabled = sound.TimePosition >= 5 and sound.TimePosition < 20
242238
end)
243239
```
244240

content/en-us/tutorials/fundamentals/coding-5/intro-to-arrays.md

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,7 @@ Use the array size to check when it's time to cycle back to the first piece of d
202202
local dialogue = dialogueArray[dialogueIndex]
203203
Chat:Chat(head, dialogue)
204204

205-
if dialogueIndex == #dialogueArray then
206-
dialogueIndex = 1
207-
else
208-
dialogueIndex += 1
209-
end
205+
dialogueIndex = if dialogueIndex == #dialogueArray then 1 else dialogueIndex + 1
210206
end
211207
```
212208

@@ -239,12 +235,7 @@ This script used an array to create a list of possible dialogue lines for a Non-
239235
local dialogue = dialogueArray[dialogueIndex]
240236
Chat:Chat(head, dialogue)
241237

242-
if dialogueIndex == #dialogueArray then
243-
dialogueIndex = 1
244-
245-
else
246-
dialogueIndex += 1
247-
end
238+
dialogueIndex = if dialogueIndex == #dialogueArray then 1 else dialogueIndex + 1
248239
end
249240

250241
prompt.Triggered:Connect(speak)

0 commit comments

Comments
 (0)