introduction = "Hello World"
standard_greeting = SubString(introduction, 1:5)
println(standard_greeting) # Will print Hello.
standard_greeting = SubString(introduction, 1,5)
println(standard_greeting) # Will print Hello.
- Is there any difference between using
,
or:
when using theSubString()
method?
This is interesting, and I’m aware the Python is not Julia, but in Python, doing:
introduction = "Hello World"
print(introduction[1:5].strip()) # Will print ello
In Julia:
introduction = "Hello World"
standard_greeting = SubString(introduction, :5) # Will print o World
println(standard_greeting)
Python:
introduction = "Hello World"
print(introduction[:5].strip()) # Will print Hello
- In Julia,
:5
is equivalent as saying start at index 5, is that the correct way of thinking about it?