# The combination of parse and length

**URL:** https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282
**Category:** General Usage
**Created:** [November 5, 2024, 12:25pm UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282 "2024-11-05T12:25:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hack3rcon](https://avatars.discourse-cdn.com/v4/letter/h/96bed5/32.png) [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)
#### Post date: [November 5, 2024, 12:25pm UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282/1 "2024-11-05T12:25:42Z")

</div>

Hello,  
Why is the following combination wrong?

```julia
w = "Hello"
print(parse(Int,length(w)))

```

Thank you.

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [November 5, 2024, 12:28pm UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282/2 "2024-11-05T12:28:36Z")

</div>

> [@hack3rcon](#):
>
> ```julia
> w = "Hello"
> print(parse(Int,length(w)))
> 
> ```

`length(w)` is already an integer, you don’t need to `parse` it.

---

<div class="post-metadata">

### Author: ![hack3rcon](https://avatars.discourse-cdn.com/v4/letter/h/96bed5/32.png) [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)
#### Post date: [November 6, 2024, 6:32am UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282/3 "2024-11-06T06:32:55Z")

</div>

Hi,  
Thanks.  
So, when we try to convert one type to the same type, we get an error.

---

<div class="post-metadata">

### Author: ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)
#### Post date: [November 6, 2024, 7:38am UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282/4 "2024-11-06T07:38:16Z")

</div>

> [@hack3rcon](#):
>
> So, when we try to convert one type to the same type, we get an error.

`convert` is different, `convert(::Type{T}, x::T} -> x` is generically defined, so you can `convert(Int, 2)`. However, `parse` is something you specifically do to string-ly values, hence the error you saw.

---

<div class="post-metadata">

### Author: ![hack3rcon](https://avatars.discourse-cdn.com/v4/letter/h/96bed5/32.png) [@hack3rcon](https://discourse.julialang.org/u/hack3rcon)
#### Post date: [November 16, 2024, 9:05am UTC](https://discourse.julialang.org/t/the-combination-of-parse-and-length/122282/5 "2024-11-16T09:05:01Z")

</div>

Hi,  
Thank you so much for your reply.  
I didn’t mean the `convert` function.
