# Inspect the signature of a function

**URL:** <https://forums.swift.org/t/inspect-the-signature-of-a-function/42136>\
**Category:** Using Swift\
**Created:** [November 19, 2020, 12:04pm UTC](https://forums.swift.org/t/inspect-the-signature-of-a-function/42136 "2020-11-19T12:04:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lukzett](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@lukzett](https://forums.swift.org/u/lukzett)\
**Post date:** [November 19, 2020, 12:04pm UTC](https://forums.swift.org/t/inspect-the-signature-of-a-function/42136/1 "2020-11-19T12:04:52Z")

</div>

Let's say I have a function

```swift
func something(a: SomeType, b: (AnotherType) -> YetAnotherType) {
  // ...
}

```

Can I get the type of `a` or `b` so I can use it in a declaration?

Instead of writing

```swift
  let test: SomeType?
  let block: (AnotherType) -> YetAnotherType = { .. }

```

I would like to write something along the lines of:

```swift
let test: typeOf(#selector(something), at: 0)
let block: typeOf(#selector(something), at: 1) = { .. }

```

Also something similar for the return type would be nice.

Basically those types can get a bit verbose, I'm looking how to write less and clearer..

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [November 19, 2020, 4:50pm UTC](https://forums.swift.org/t/inspect-the-signature-of-a-function/42136/2 "2020-11-19T16:50:56Z")

</div>

Such dynamic usage isn't possible in Swift (I'll leave it to others to explain exactly why). But if you need less verbose types, use a `typealias`, especially for closure types.
