Laravel 5之前的请求路径(Laravel 5 previous request path)
Laravel中是否有任何内置方法来获取上一个URL的路径?
我知道
url()->previous();
但我只想得到以前的路径。 此外,我可以从以前的URL中提取以前的路径。 但是我想知道Laravel中是否有任何内置方法。Is there any built-in method in Laravel to get the path of the previous URL?
I know about
url()->previous();
but i only want to get previous path. Also, I can extract previous path from the previous URL. But I would like to know if there is any built-in method in Laravel.
原文:https://stackoverflow.com/questions/47110513
更新时间:2023-05-25 20:05
最满意答案
您不需要
Enumerable.Range
和Zip
方法,因为您可以使用为您提供索引的Select
重载:var dict = File.ReadLines(wordsFile) .Select((word, index) => new { word, index }) .ToDictionary(x => x.word, x => x.index + 1);
You don't need the
Enumerable.Range
andZip
approach since you can use theSelect
overload that gives you the index:var dict = File.ReadLines(wordsFile) .Select((word, index) => new { word, index }) .ToDictionary(x => x.word, x => x.index + 1);
相关问答
更多-
基于
的范围(Range based for with pair [2021-10-01]) 在基于范围的for循环中,非成员begin()和end()名称查找仅使用ADL。 它不执行普通的不合格查找。 §6.5.4[stmt.ranged] /p1.3: 如果_RangeT是一个类类型,那么在类_RangeT的范围内查找非限定id的begin和end就好像通过类成员访问查找(3.4.5)一样,并且如果(或两者)至少发现一个声明, [...] 否则, begin-expr和end-expr分别是begin(__range)和end(__range) , begin和end在相关的命名空间(3.4.2 ... -
向后阅读文本文件真的很棘手,除非您使用固定大小的编码(例如ASCII)。 当您具有可变大小编码(例如UTF-8)时,您将不得不检查在获取数据时是否位于字符中间。 框架中没有内置的东西,我怀疑你必须为每个变宽编码分别进行硬编码。 编辑:这已经有些测试 - 但这并不是说它还没有一些细微的错误。 它使用MiscUtil的StreamUtil,但是我已经从底部添加了必要的(新)方法。 哦,它需要重构 - 有一个非常大的方法,你会看到: using System; using System.Collections; ...
-
这条规则以及其他一些相关规则在Eric Lippert的博客文章中讨论。 这里违反的特定规则是: 2)在同一局部变量声明空间或嵌套局部变量声明空间中有两个相同名称的局部变量是非法的。 特别值得注意的是,至于规则存在的原因如下: 所有这些规则的目的都是为了防止代码的读者/维护者被欺骗的错误类别认为他们所指的是一个具有简单名称的实体,但实际上是完全意指另一个实体。 这些规则特别旨在防止执行应该是安全重构时的令人讨厌的意外。 通过允许您描述的内容可能会导致看似良性的重构,例如将for循环移到另一个声明之后,从而导 ...
-
基于从java到c#的迭代器等效的索引写入remove方法(Write remove method at index based on iterator equivalent from java to c#)[2023-11-04]
C#/ .Net迭代器(由IEnumerable返回的IEnumerable )是只读向前的迭代器,与Java的iterator.remove相比,不允许从底层集合中删除项目。 大多数集合支持通过索引删除项目,如List .RemoveAt ,它们将近似等效。 或者,如果您只想在迭代期间跳过项目 - Enumarable.Skip或Enumerable.Where可以是一个选项: mySequence.Where((item,id) => id != indexToSkip) C#/ ... -
如果所有的“片段”都是可Clone则迭代器通常都是可Clone 。 在my_iter中你有几个不是这样的:匿名闭包(就像flat_map中的那个)和to_uppercase返回的ToUppercase结构。 你可以做的是: 重建整个事情(如@ArtemGr建议)。 你可以使用宏来避免重复。 有点丑,但应该工作。 在填充my_struct之前收集my_iter到一个Vec (因为您好像在那里收集它): let my_iter: Vec
= my_string.unwrap_or("A").char ... -
真的有关系吗? 这些是你必须尽量避免恕我直言的微观优化类型。 此外,即使迭代时间在地图上的大量元素中发生变化,您尝试遍历如此大地图的所有元素的事实意味着最有可能您选择了错误的数据结构。 Does it really matter? these are the types of the micro optimizations you must try to avoid IMHO. Also, even if the iteration time changes for very large number of ...
-
C#中快速高效的迭代器(Fast and efficient iterator in C#)[2022-07-16]
您不需要Enumerable.Range和Zip方法,因为您可以使用为您提供索引的Select重载: var dict = File.ReadLines(wordsFile) .Select((word, index) => new { word, index }) .ToDictionary(x => x.word, x => x.index + 1); You don't need the Enumerable.Range and Zip approach since you can ... -
您可以放弃foreach并直接处理IEnumerator
。 using (IEnumerator< > enumerator = dict.GetEnumerator()) { while (enumerator.MoveNext()) { DoSomething(enumerator.Current); if (condition) break; } while (enume ... -
你看过莎莉了吗? 我没有使用它,但它看起来很相关 Have you looked at sary? I haven't used it but it looks relevant
-
如何以优雅高效的方式实现各种迭代器类别?(How can I implement various iterator categories in an elegant and efficient way?)[2023-11-01]
我认为你应该使用CRTP( https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern )。 喜欢这个: templatestruct iiterator_t { typedef T value_type; typedef T& reference; typedef T* pointer; typedef ItT iterator_type; ...